Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to load external Lua file #18

Closed
xu4wang opened this issue Nov 30, 2015 · 8 comments
Closed

failed to load external Lua file #18

xu4wang opened this issue Nov 30, 2015 · 8 comments

Comments

@xu4wang
Copy link

xu4wang commented Nov 30, 2015

I am using mac os, with openresty 1.9.3.2

The issue I met is similar to:
http://stackoverflow.com/questions/28087228/openresty-content-by-lua-file

The server cannot load external Lua script:
2015/11/30 21:03:06 [error] 61190#0: *1 failed to load external Lua file "/Users/wangxu/Documents/work/tms/dev/tms/lua/req.lua": cannot open /Users/wangxu/Documents/work/tms/dev/tms/lua/req.lua: Permission denied, client: 127.0.0.1, server: , request: "GET /v1/p HTTP/1.1", host: "127.0.0.1"

However If I copy the lua file into /tmp and use
content_by_lua_file "/tmp/req.lua";

Everything is OK.

I checked the path, the permissions.. they are all correct.

@agentzh
Copy link
Member

agentzh commented Nov 30, 2015

@xu4wang This is really about basic *NIX permissions, not OpenResty. To solve a path (by the OS), all the directories on the path should be executable by the current system account, not just the file being readable. This is why putting the file under /tmp works for you since the /tmp directory itself is very permissive.

@xu4wang
Copy link
Author

xu4wang commented Nov 30, 2015

Thanks for the quick response... Problem solved.
I realized the worker process is running under nobody instead of root, even I run nginx with sudo..

@xu4wang xu4wang closed this as completed Nov 30, 2015
@crockpotveggies
Copy link

Visitor from the future with a permissions-based problem. Ran into a similar issue where the process is running as nobody. Does anyone know how to run it as root? Not concerned about security, this isn't a public service.

@crockpotveggies
Copy link

Nevermind, solved this rather quickly. It can be done with the nginx config:

user root root;

@agentzh
Copy link
Member

agentzh commented Aug 14, 2016

@crockpotveggies It's a bad idea to run the nginx workers as root in production though since it exposes higher security risk (once the hacker gets his way into the nginx worker, he becomes root).

@crockpotveggies
Copy link

It's a private network not exposed to the outside Internet. Nuff said 😉
On Sat, Aug 13, 2016 at 6:51 PM Yichun Zhang notifications@github.com
wrote:

@crockpotveggies https://github.com/crockpotveggies It's a bad idea to
run the nginx workers as root in production though since it exposes
higher security risk (once the hacker gets his way into the nginx worker,
he becomes root).


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#18 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABYNrwf1K8Ujt7AIoj1f3yZY7K6Us5bWks5qfnR9gaJpZM4GrayH
.

@transtone
Copy link

transtone commented Dec 3, 2020

In my Gentoo, to avoid 404, It must set these two steps:

  1. file use a absolute path.
  2. add charset like: charset utf-8;

==========================
使用外部 lua 文件,必须使用绝对路径,且需要指定文件编码: charset utf-8;

@duan1998
Copy link

image
after modifing this text from "user : nobody" to "user : my user name",everything is ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants