是否可以指定相对于包含conf文件的rootpath?
我们正在开发一个Web应用程序,并在项目的目录中保存具有应用程序特定configuration的app-nginx.conf文件。 我希望能够将这个文件包含在主要的nginx.conf文件中,并且具有正确引用所需项目子目录的rootpath。 例:
# /etc/nginx/nginx.conf http { include /absolute/path/to/app/app-nginx.conf } # /absolute/path/to/app/app-nginx.conf server { server_name localhost; listen 9090; root ./app; }
以相似的configuration启动nginx之后,nginx尝试parsing相对于nginx安装目录( /usr/local/Cellar/nginx/1.4.3/ )的./apppath,而不是应用程序的目录。
是否可以指定相对于包含conf文件的根path?
没有。
Nginx默认只在编译时知道设置为--prefix的path(参考http://nginx.org/en/docs/configure.html )。 所以, 该path用于任何相对path。
根据官方文档( http://nginx.org/r/root ),虽然root指令可以包含其他variables。
我还没有find一种方法来使用相对path或定义全局variables,但这个小技巧解决了我的问题。