lua-nginx-module
lua-nginx-module copied to clipboard
attempt to call field 'exit' (a nil value)
CentOS Linux release 7.9.2009 (Core)
lua-nginx-module-0.10.20
luajit -v
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2021 Mike Pall. https://luajit.org/
nginx -V
nginx version: nginx/1.19.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.1.1g 21 Apr 2020
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-openssl=/data/install/lnmp1.7/src/openssl-1.1.1g --with-openssl-opt=enable-weak-ssl-ciphers --add-dynamic-module=/usr/local/nginx/module/headers-more-nginx-module --add-dynamic-module=/home/jsx/lua-nginx-module-0.10.20 --add-dynamic-module=/home/jsx/redis2-nginx-module-0.15/ --add-dynamic-module=/home/jsx/echo-nginx-module-0.62/
demo.com.conf
# ...
location / {
access_by_lua_file /usr/local/nginx/conf/lua/ip.lua;
try_files $uri $uri/ /index.php?$query_string;
}
# ...
/usr/local/nginx/conf/lua/ip.lua
ngx.status = ngx.HTTP_GONE
ngx.say("This is our own content")
return ngx.exit(ngx.HTTP_GONE)
error.log
2022/01/10 16:07:50 [error] 28446#0: *60 lua entry thread aborted: runtime error: /usr/local/nginx/conf/lua/ip.lua:3: attempt to call field 'exit' (a nil value)
stack traceback:
coroutine 0:
/usr/local/nginx/conf/lua/ip.lua: in function </usr/local/nginx/conf/lua/ip.lua:1>, client: 10.18.68.142, server: demo.com, request: "GET / HTTP/1.1", host: "demo.com"
What's going on here
content_by_lua "ngx.exit(403);ngx.say('hi')";
2022/01/10 17:08:40 [error] 12768#0: *3 lua entry thread aborted: runtime error: content_by_lua(demo.chengjiukehu.com.conf:18):1: attempt to call field 'exit' (a nil value)
stack traceback:
ngx.say(ngx.var)
nil
User-Agent: curl/7.30.0 Host: testtest.com:8899 Accept: / Content-Length: 336 Content-Type: application/x-www-form-urlencoded
- upload completely sent off: 336 out of 336 bytes < HTTP/1.1 410 Gone < Date: Fri, 11 Feb 2022 10:30: GMT < Content-Type: text/html; charset=utf-8 < Transfer-Encoding: chunked < Connection: keep-alive < Server: olwaf system < This is our own content
No problem like what you do. Please check your basic operating environment.