On Fri, Feb 13, 2015 at 01:07:15AM -0500, malintha wrote:
proxy_set_header Host $http_host;
When I configure like this nginx resolve it to (stop decoding but incorrect
URL - adding /gateway/)
/gateway/malintha/tel%3A%2B6281808147137
What makes you think that nginx is adding “/gateway/”? As per
the location specification, the $request_uri is expected to
contain “/gateway/” in it.
but When I remove $request_uri it resolve to correct URL (but with
decoding)
With $request_uri in proxy_pass nginx will assume you’ve specified
full URI yourself and it shouldn’t be changed. When you remove
$request_uri nginx will follow it’s normal logic to replace
matching part of $uri with the URI part specified in the
proxy_pass directive, and will encode the result as appropriate.
See Module ngx_http_proxy_module for details.
If you want nginx to preserve the encoding as it was in the
original client request, and want to strip “/gateway/” part from
the URI at the same time, you may do so by manually removing the
“/gateway/” from the $request_uri variable, like this (untested):
set $modified_uri $request_uri;
if ($modified_uri ~ "^/gateway(/.*)") {
set $modified_uri $1;
}
proxy_pass http://upstream$modified_uri;
Note though, that this will not work in some characters in the
“/gateway/” are escaped by the client.