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"
慕哥6287543