在Lua中,可以通过ngx.var来获取和设置nginx的变量。要将变量设置到proxy_set_header指令中的test值中,可以使用以下代码:

ngx.var.test = "your_value"

然后,在相应的proxy_pass指令下面添加proxy_set_header指令:

location / {
    proxy_pass http://your_upstream;

    proxy_set_header test $test;
}

这样,Lua中设置的test变量的值就会被传递给nginx的proxy_set_header指令中的test值。

lua 返回变量设置到nginx proxy_set_header test 的value 中

原文地址: http://www.cveoy.top/t/topic/iR4L 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录