嗨,是否可以包括与lua到nginx的文件。
例如,lua连接到数据库,如果brotli的值是打开的,那么它就启用brotli并导入它的配置文件。
if (brotli = true) {
brotli on;
include /etc/djsfh/ll.conf
}发布于 2022-07-05 13:42:42
不是的。Nginx不是一个可执行脚本,而是一个声明性配置文件(除了重写来自重写模块的指令的请求处理阶段 NGX_HTTP_SERVER_REWRITE/NGX_HTTP_REWRITE和执行之外)。在nginx启动期间,只对配置进行一次解释。根据您的配置,可能的解决方案之一可以是条件跳转到两个指定位置之一,首先使用brotli配置,然后不使用它:
rewrite_by_lua_block {
local use_brotli = ... -- get the true/false value from database
local jumpto = use_brotli and '@use_brotli' or '@dont_use_brotli'
ngx.exec(jumpto)
}
location @use_brotli {
brotli on;
include /etc/djsfh/ll.conf
...
}
location @dont_use_brotli {
...
}根据实际使用的配置,此示例可能需要其他修改。
https://stackoverflow.com/questions/72869479
复制相似问题