tell nginx to stay inside same location?
Edho Arief
me at myconan.net
Thu Jul 30 15:02:16 UTC 2015
On Thu, Jul 30, 2015 at 11:57 PM, Gregory Edigarov <edigarov at qarea.com> wrote:
> Hello,
>
> is that possible to tell nginx to stay inside the same location after
> rewrite rule is done?
>
> i.e. I have:
>
> location /njs/ {
> proxy_pass http://localhost:5501;
> ......
> }
>
> now, if i need to cut off /njs/ part, i added the following:
> location /njs/ {
> rewrite /njs(.*) $1;
> proxy_pass http://localhost:5501;
> ..........
> }
>
> but, that doesn't work, because my uri has changed and nginx goes to the
> default location, which I don't need.
>
> what could I do in this situation?
>
if only you have read the documentation...
http://nginx.org/r/proxy_pass
...
When the URI is changed inside a proxied location using the rewrite
directive, and this same configuration will be used to process a
request (break):
location /name/ {
rewrite /name/([^/]+) /users?name=$1 break;
proxy_pass http://127.0.0.1;
}
In this case, the URI specified in the directive is ignored and the
full changed request URI is passed to the server.
...
More information about the nginx
mailing list