set $test '+++';
# test.lua 中修改$test变量的值为haha
access_by_lua_file "./test.lua";
location /test {
root /var/work/www/;
# 再nginx错误日志中输出$test的值
set_by_lua $res 'ngx.log(ngx.ERR, ngx.var.test)';
}
为什么输出的结果还是+++呢? 并不是修改后的haha呢?
我再test.lua里面也加了ngx.log输出debug信息, 发现set_by_lua里面的ngx.log居然在test.lua运行之前就已经输出了。难道set_by_lua指令是运行再access_by_lua_file之前吗?
有什么方法能再access_by_lua_file里面修改变量的值, 再set_by_lua里面可以获得修改后的值呢?