先贴出代码片段:
location /test_post {
internal;
set $api "http://test.com.cn/$wfunction?$args";
proxy_method POST;
proxy_pass $api;
}
location /test {
lua_code_cache off;
set $wfunction "test/echo.json";
content_by_lua '
local array = ngx.req.get_uri_args()
local uid = array.uid
local appkey = "11111111111"
local res = ngx.location.capture("/test_post",
{ method = ngx.HTTP_POST, args = { source = appkey, uid = uid },
share_all_vars = true }
)
if res.status == ngx.HTTP_OK then
ngx.header.content_type = 'application/json'
local json = res.body
ngx.say(json)
else
ngx.header.content_type = "text/html"
ngx.say(res.status, ": body :", res.body, ": uid :", uid)
end
';
}
对于这个使用,我有几个疑问:
1、这么用我原始请求 /test 的用户cookie可以顺序传递给proxy访问的页面吗?
2、如不能传递过去,应该如何进行。。。(最终proxy代理访问的页面需要cookie验证用户信息)
请教各位大神。。。。