1
回答
ngx_lua的set_by_lua_file在/下会被调用两次

nginx.conf里配置

set_by_lua_file $flag conf/lua/test.lua;

conf/lua/test.lua文件内容是:

ngx.log(ngx.ERR, 'called')

然后直接请求curl http://127.0.0.1:8081/

在查看nginx的error_log,发现里面有两个

2015/03/13 17:00:48 [error] 2174#0: *2314 [lua] test.lua:1: called, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "127.0.0.1:8081"
2015/03/13 17:00:48 [error] 2174#0: *2314 [lua] test.lua:1: called, client: 127.0.0.1, server:localhost, request: "GET / HTTP/1.1", host: "127.0.0.1:8081"

但如果是请求其他的url,却只有记录了一次

2015/03/13 17:03:26 [error] 2173#0: *2316 [lua] test.lua:1: called, client: 127.0.0.1, server:localhost, request: "GET /project/projects HTTP/1.1", host: "127.0.0.1:8081"

这是啥原因导致的?

举报
leo108
发帖于3年前 1回/2K+阅
顶部