我有一个反向 nginx 代理在 nginx.config 中运行以下内容:
http {
lua_package_path ";;$prefix/?.lua;?.lua;/etc/nginx/?.lua;/etc/nginx/resty/?.lua;";
}
然后在服务器中的多个位置:
# xxx SERVICE
location ~* ^/articles/?(.*) {
proxy_ignore_client_abort on;
include cors.conf;
access_by_lua_file nginx_v4.lua;}
我在/etc/nginx/使用 nginx 和 lua 配置运行这个 centos 7,以及我在 lua 包路径中给出的内容。当我运行 nginx 时,可以正常导入 lua 文件(在 lua_package_path 中找到它),但是由于某种原因,当我运行 xxx 服务时,它会失败并显示以下内容:
> 2016/10/11 16:37:21 [notice] 19300#0: getrlimit(RLIMIT_NOFILE):
> 1024:4096 2016/10/11 16:37:21 [notice] 19301#0: start worker processes
> 2016/10/11 16:37:21 [notice] 19301#0: start worker process 19303
> 2016/10/11 16:37:25 [error] 19303#0: *1 failed to load external Lua
> file "/usr/share/nginx/nginx_v4.lua": cannot open
> /usr/share/nginx/nginx_v4.lua: No such file or directory, client:
> 10.1.104.135, server: localhost, request: "GET /content/search?filter.search_string=goog HTTP/1.1", host: "x.x.x.x"
> 2016/10/11 16:37:41 [info] 19303#0: *2 client closed connection while
> waiting for request, client: 10.1.104.135, server: 0.0.0.0:443
出于某种原因,它会在 /usr/share/nginx 中查找实际位于 /etc/nginx 中的 lua 文件:**file "/usr/share/nginx/nginx_v4.lua": 无法打开
/usr/share/nginx/nginx_v4.lua:没有这样的文件或目录**
知道为什么吗?在我硬编码路径之前,这不起作用。