Hello!
2015-03-02 1:29 GMT-08:00 <j...@xinzhang.info>:
> lua代码如下:
>
> local res = ngx.location.capture("/proxy0" .. ngx.var.uri, { args =
> ngx.var.args })
> if res.status == 302 then
> ngx.say(res.body)
> else
> ngx.say(res.body)
> end
> 请问:红色代码应该如何修改才能达到我的要求?
你这里其实需要的是把子请求的响应头转发给主请求,可以在 ngx.location.capture 调用成功之后这么写:
local resp_header
for k, v in pairs(res.header) do
resp_header[k] = v
end
Regards,
-agentzh