September 13, 2013 08:48AM
Hi,

According to documentation, "location" matches only against URI path, ignoring query string. However, after "rewrite", when using variables containing "?" character (like $request_uri for illustration), query becomes part of $uri:

location /src/ {
rewrite ^ /dst$request_uri;
}

location /dst/ {
# At this point, $uri contains query part from /src, like /dst/src/?arg=val
add_header Content-Type text/plain;
return 200 "$request_uri $uri $args";
}

For request like "/src/?arg=val" the output will be: /src/?arg=val /dst/src/?arg=val arg=val

Thus, $uri (and matched part) contains query, and $args *also* contains query (inherited from original request). All together, this may lead to quite unexpected results in some configurations.

So, my question is - is this expected behavior (just undocumented) or is a bug? To me it looks like a bug - allowing matching anything past "?" in location and making it part of $uri.
Subject Author Posted

query part included in location match after rewrite (bug or feature?)

aldem September 13, 2013 08:48AM

Re: query part included in location match after rewrite (bug or feature?)

Francis Daly September 13, 2013 09:20AM

Re: query part included in location match after rewrite (bug or feature?)

aldem September 13, 2013 09:48AM

Re: query part included in location match after rewrite (bug or feature?)

Francis Daly September 13, 2013 10:28AM

Re: query part included in location match after rewrite (bug or feature?)

aldem September 13, 2013 10:51AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 193
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