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

leo108 发布于 2015/03/14 01:15
阅读 2K+
收藏 0

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"

这是啥原因导致的?

加载中
0
Altman
Altman
set好像是有一次url rewrite,我一般用content_by_lua_file
返回顶部
顶部