nginx变量,用于配置文件的路径

编程入门 行业动态 更新时间:2024-10-28 22:23:35
本文介绍了nginx变量,用于配置文件的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

例如,是否有一种方法可以指定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变量,用于配置文件的路径

本文发布于:2023-10-07 10:56:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469210.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   配置文件   路径   nginx

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!