【???】nginx_lua问题记录
2015-03-10 13:42
323 查看
问题1:
当用http://localhost/test 访问时,结果为何迥异?
eg1 :
结果为空,说明执行的是HttpEchoModule的echo指令,没有执行httpLuaModule的content_by_lua指令
eg2:
eg3:
输出:
456
456
说明执行的是HttpEchoModule的echo指令,没有执行httpLuaModule的content_by_lua指令
eg4:
输出:456
说明执行的是httpLuaModule的content_by_lua指令,没有执行HttpEchoModule的echo指令
综上四个例子的结论:
nginx的content_phases只能注册一个第三方的module。HttpEchoModule和httpLuaModule都注册在这个phases,当一个location同时又两个第三方的module注册content phase时,只能有一个注册成功,在这里HttpEchoModule和httpLuaModule 只能有一个注册成功,至于是谁注册成功,这是不确定的。
问题2:
access_by_lua rewrite_by_lua content_by_lua 三个块交换顺序有什么影响吗?主要想了解nginx执行的不同phase
问题3:
解决方法:是关闭nginx.conf中的 lua_code_cache 开关,改为off
但是生产环境下的时候这个开关必须为on,怎么办?
参见这里:
https://www.fullautocapitalism.com/openresty%20lua-nginx-module%20%E9%83%A8%E5%88%86%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3(lua_code_cache)
https://github.com/openresty/lua-nginx-module#lua_code_cache
https://groups.google.com/forum/#!topic/openresty/W0dvD5Wm0Bw
https://groups.google.com/forum/#!msg/openresty/qy3wDk6z038/crKmpmRwyOsJ
https://groups.google.com/forum/#!topic/openresty/kkr10J-__U0
https://github.com/openresty/lua-nginx-module/issues/272
当用http://localhost/test 访问时,结果为何迥异?
eg1 :
location /test { set $test ''; content_by_lua ' ngx.var.test = 123; ngx.say(ngx.var.test); '; echo $test; # }
结果为空,说明执行的是HttpEchoModule的echo指令,没有执行httpLuaModule的content_by_lua指令
eg2:
location /test { set $test ''; echo "yyy"; # echo "zzz"; # content_by_lua ' ngx.var.test = 123; ngx.say(ngx.var.test); '; }输出123 ,说明执行的是httpLuaModule的content_by_lua指令,没有执行HttpEchoModule的echo指令
eg3:
location /test1 { set $a 123; content_by_lua ' ngx.say(ngx.var.a) '; echo $a; set $a 456; echo $a; }
输出:
456
456
说明执行的是HttpEchoModule的echo指令,没有执行httpLuaModule的content_by_lua指令
eg4:
location /test1 { set $a 123; echo $a; set $a 456; echo $a; content_by_lua ' ngx.say(ngx.var.a) '; }
输出:456
说明执行的是httpLuaModule的content_by_lua指令,没有执行HttpEchoModule的echo指令
综上四个例子的结论:
nginx的content_phases只能注册一个第三方的module。HttpEchoModule和httpLuaModule都注册在这个phases,当一个location同时又两个第三方的module注册content phase时,只能有一个注册成功,在这里HttpEchoModule和httpLuaModule 只能有一个注册成功,至于是谁注册成功,这是不确定的。
问题2:
access_by_lua rewrite_by_lua content_by_lua 三个块交换顺序有什么影响吗?主要想了解nginx执行的不同phase
location /test { rewrite_by_lua ' ngx.say("foo = ", ngx.ctx.foo) ngx.ctx.foo = 76 '; access_by_lua ' ngx.ctx.foo = ngx.ctx.foo + 3 '; content_by_lua ' ngx.say(ngx.ctx.foo) '; }
问题3:
[root@de73cd1ca978 nginx]# sbin/nginx -s reload [root@de73cd1ca978 nginx]# curl -d "uid=2646095867" http://localhost/statuses/friends_timeline 1 110.210.130.21:807710.210.130.21:8078 path2 [root@de73cd1ca978 nginx]# curl -d "uid=2646095867" http://localhost/statuses/friends_timeline [root@de73cd1ca978 nginx]#reload nginx配置以后,第一遍请求有内容,为何第二遍请求没有内容了?
解决方法:是关闭nginx.conf中的 lua_code_cache 开关,改为off
但是生产环境下的时候这个开关必须为on,怎么办?
参见这里:
https://www.fullautocapitalism.com/openresty%20lua-nginx-module%20%E9%83%A8%E5%88%86%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3(lua_code_cache)
https://github.com/openresty/lua-nginx-module#lua_code_cache
https://groups.google.com/forum/#!topic/openresty/W0dvD5Wm0Bw
https://groups.google.com/forum/#!msg/openresty/qy3wDk6z038/crKmpmRwyOsJ
https://groups.google.com/forum/#!topic/openresty/kkr10J-__U0
https://github.com/openresty/lua-nginx-module/issues/272
相关文章推荐
- 记录nginx两种问题解决
- Ubuntu上安装nginx步骤及问题记录
- cocos-lua问题记录
- nginx问题记录
- nginx配置反向代理或跳转出现400问题处理记录
- nginx日志问题解决方法记录
- Lua501版本编译tolua5.2.4版本的问题解决记录
- 记录lua的table转string一个问题
- cocos2dx-lua里面class的实现的一些问题记录和思考
- 记录当前项目lua内存泄露问题
- Lua table.remove 的一个问题记录
- 记录给nginx增加模块过程中碰到的问题
- nginx + tomcat + redis问题记录
- 记录一下Quick-Cocos2dx-Community lua绑定C++自定义类遇到的问题
- 遇到了nginx 在win2008 下启动不了的问题,记录一下解决的方法
- nginx重启问题处理记录
- [问题记录]cocos的lua绑定安装pyyaml报错
- nginx使用问题记录
- openwrt 问题二 js 通过nginx 服务器调用 lua代码的过程实现
- [问题记录]按url context path设置nginx反向代理禅道和Jenkins