通过ngx.location.capture发起的子请求.经过 location转发到 php 后. 获得的是父请求.请问怎么让 php 获取子请求?

56 views
Skip to first unread message

kangkang han

unread,
Dec 28, 2016, 9:12:25 AM12/28/16
to openresty
麻烦问下大家
通过ngx.location.capture发起的子请求.经过 location 转发到 php 后.
php代码接收到的依旧是父请求.请问怎么搞,才能让 php 获得的是子请求?
谢谢大家.

杨关道

unread,
Dec 28, 2016, 11:05:46 AM12/28/16
to openresty
你要在那个location中封装你的请求,我才你是想要是类似这样的location

location /backend {
        internal;
        rewrite_by_lua 'ngx.req.set_uri(ngx.var.backend_uri)';
        proxy_http_version 1.1;
        proxy_set_header Connection KeepAlive;
        proxy_set_header CLIENTADDR $remote_addr;
        proxy_set_header Content-Type application/x-www-form-urlencoded;
        proxy_pass $backend_host;
    }

其中$backend_host和$backend_uri是capture调用中传过来的

在 2016年12月28日星期三 UTC+8下午10:12:25,kangkang han写道:
Reply all
Reply to author
Forward
0 new messages