nginx升级成openresty后,lua脚本中ngx.var读取不到:
nginx.conf
lua_package_path "/usr/local/openresty/nginx/conf/lua/redis.lua;;";
server {
location /hello {
default_type 'text/plain';
access_by_lua_file /usr/local/openresty/nginx/conf/lua/ip_limitlist.lua;
content_by_lua 'ngx.say("hello,lua")';
}
}
ip_limitlist.lua:
......
local ip = ngx.var.remote_addr
......
请求接口直接报错:
lua entry thread aborted: runtime error:/usr/local/openresty/nginx/conf/lua/ip_limitlist.lua:7:attempt to index field 'var' (a nil value)