proxy_pass and trailing / decode uri

max maxima078 at gmail.com
Mon Mar 12 08:59:01 UTC 2018


Sorry for double post:
>
> I guess the only way to remove the /api part is "rewrite" and involves
> re-encoding...

=>   I guess the only way to remove the /api without re-encoding URI is
"rewrite" ...

Max

2018-03-12 9:55 GMT+01:00 max <maxima078 at gmail.com>:

> Hi,
>
> When you want nginx to replace matching part of the URI with "/",
>> it will do so on the decoded/normalized URI, and will re-encode
>> special characters in what's left.
>>
>> If you want nginx to preserve original URI as sent by the client,
>> consider using proxy_pass without the URI part.  That is,
>> instead of
>>
>>     proxy_pass http://127.0.0.1:82/;
>>
>> use
>>
>>     proxy_pass http://127.0.0.1:82;
>>
>> Note no trailing "/".  This way the original URI as sent by the
>> client will be preserved without any modifications.
>>
>
>
> Thank you for your answer but it is not correct for location different
> than '/'. With your proposal, targeting http://domain1.com/api/foo/bar,
> socket on port 82 receives: /api/foo/bar. I guess the only way to remove
> the /api part is "rewrite" and involves re-encoding...
>
> Max.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20180312/e541893d/attachment-0001.html>


More information about the nginx mailing list