例如,是否有一种方法可以指定root应该相对于配置文件所在的目录?像
root $conf_path/www解决方案
通常,我认为这是不可能的.但是,您可能可以根据本文. >
引用相关部分:
2版本在这里: 如何在nginx.conf中引用操作系统环境变量
发布在Nginx论坛上: forum.nginx/read.php? 2,215269,215278#msg-215278
进一步
您可以在启用了ngx_lua的情况下读取系统环境变量 nginx构建: wiki.nginx/HttpLuaModule
env PATH; http { ... server { location /path { set_by_lua $path 'return os.getenv("PATH")'; ... } }
顺便说一句,要使用set_by_lua指令,您还需要启用 此处的ngx_devel_kit模块: github/simpl/ngx_devel_kit (如果使用ngx_openresty捆绑包会更容易).
Is there a way to specify, for example, that the root should be relative to the directory where the config file is living? Something like
root $conf_path/www解决方案
In general, I don't believe this is possible. But, you might be able to hack something together based on this article.
Quoting relevant parts:
2ed version is here: How to reference OS Environment Variables in nginx.conf
Posted at Nginx Forum: forum.nginx/read.php?2,215269,215278#msg-215278
and further
You can read system environment variables with ngx_lua enabled in your nginx build: wiki.nginx/HttpLuaModule
env PATH; http { ... server { location /path { set_by_lua $path 'return os.getenv("PATH")'; ... } }
BTW, to use the set_by_lua directive, you also need to enable the ngx_devel_kit module here: github/simpl/ngx_devel_kit (it'll be easier if you use the ngx_openresty bundle).
更多推荐
nginx变量,用于配置文件的路径
发布评论