--
邮件自: 列表“openresty”,专用于技术讨论!
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
详情: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
建议: 提问的智慧 http://wiki.woodpecker.org.cn/moin/AskForHelp
教程: http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-zhcn.html
在 Linux x86_64 上使用 nginx 1.2.4 + ngx_lua 0.7.0
运行你的示例代码无法复现你这里的错误。由于你的示例代码是不完整的,比如我不知道 body1 的初始值,也不知道你使用的是
access_by_lua, rewrite_by_lua,还是 content_by_lua,所以我自己随便假想了一下你的用法。我的
nginx.conf 片段是
location = /lua {
content_by_lua_file html/a.lua;
}
而 html/a.lua 的内容是:
local body1 = "'http://agentzh.org'"
local func = function (m)
return "\"http://"..string.reverse(m[1])
end
body1,_=ngx.re.gsub(body1,"['\"]http://(.*?)([/'\"])",func)
ngx.say(body1)
刚才我回的邮件没写完就不小心发送出去了,不好意思。下面接着写:
On Fri, Oct 12, 2012 at 11:55 AM, agentzh wrote:
> 我的 nginx.conf 片段是
>
> location = /lua {
> content_by_lua_file html/a.lua;
> }
>
> 而 html/a.lua 的内容是:
>
> local body1 = "'http://agentzh.org'"
> local func = function (m)
> return "\"http://"..string.reverse(m[1])
> end
> body1,_=ngx.re.gsub(body1,"['\"]http://(.*?)([/'\"])",func)
> ngx.say(body1)
然后请求这里定义 /lua 的结果在我这里是期望的:
所以请你也能提供像我上面给出的这样比较完整的示例,这样我才有可能在我这里复现你遇到的问题,否则就只能靠猜测了(像上面那样) :)
同时也希望你能在 bug 报告中总是主动提供像软件版本号(在这里就是 ngx_lua 和 nginx 的版本)、操作系统的种类(包括是 32
位的还是 64 位的)等重要信息。
多谢!
-agentzh
2012/10/12 朱茂海:
> 不好意思,没提供详细的描述。
> 环境:nginx-1.2.3 ngx_lua 0.7 luajit-2.0 centos-5.8 32位
> content_by_lua_file "/usr/local/nginx/conf/lua"
>
> lua代码:
>
> local func = function (m)
> return "\"http://"..string.reverse(m[1])..m[2]
> end
> body1,_=ngx.re.gsub(body1,"['\"]http://(.*?)([/'\"])",func)
>
> body1的内容为百度首页源代码。
>
多谢你提供的用例!我已经成功在我本地复现了此错误并且提交了一个补丁修正了此问题:
https://github.com/chaoslawful/lua-nginx-module/commit/3875a33
你能否再在你那里尝试一下 ngx_lua 0.7.1rc1 这个版本?
https://github.com/chaoslawful/lua-nginx-module/tags/
多谢!
Best regards,
-agentzh