Welcome! Log In Create A New Profile

Advanced

Re: Trouble with $uri in subrequest

Yichun Zhang (agentzh)
July 17, 2013 07:22PM
Hello!

On Wed, Jul 17, 2013 at 1:51 PM, ThomasLohner wrote:
> i'm having trouble getting the request_uri via lua in a subrequest.
>
> ngx.var.uri will always return the uri of the parent request whereas
> something like ngx.req.get_uri_args will return the correct args for the
> subrequest.
>
> any ideas on how to get the subrequets uri? or am i missing something here?
>

Could you please give a minimal example that can reproduce this issue?

Apparently, the following example works as expected on my side with
ngx_lua 0.8.4 + nginx 1.4.1 on Linux x86_64:

location = /sub {
internal;
content_by_lua '
ngx.say("sr uri: ", ngx.var.uri)
';
}

location = /main {
echo_subrequest GET /sub;
}

Accessing /main with curl yields

$ curl localhost:1985/main
sr uri: /sub

That is, ngx.var.uri evaluates to the URI of the subrequest, /sub, not
that of the parent request, /main.

Best regards,
-agentzh

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Trouble with $uri in subrequest

ThomasLohner July 17, 2013 04:51PM

Re: Trouble with $uri in subrequest

Yichun Zhang (agentzh) July 17, 2013 07:22PM

Re: Trouble with $uri in subrequest

ThomasLohner July 18, 2013 04:39AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 257
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready