proxy_pass redirect for address without trailing slash disregards Host port

Nuno Gonçalves nunojpg at gmail.com
Fri Aug 23 17:38:54 UTC 2019


I am using proxy_pass and I'm facing a issue which I'm not sure it's a bug.

It is in regard to the behaviour specified by the documentation [1]:

If a location is defined by a prefix string that ends with the slash
character, and requests are processed by one of proxy_pass,
fastcgi_pass, uwsgi_pass, scgi_pass, memcached_pass, or grpc_pass,
then the special processing is performed. In response to a request
with URI equal to this string, but without the trailing slash, a
permanent redirect with the code 301 will be returned to the requested
URI with the slash appended. If this is not desired, an exact match of
the URI and location could be defined like this:

Consider that there is a proxy pass for location /abcd/ { proxy_pass
... } for a server listening on port 80.

If I make a request for /abcd with Host header "example.com:8080",
then I receive a 301 for example.com/abcd/ and not for the expected
example.com:8080/abcd/.

In fact NGINX is considering the Host header domain part, but
disregarding the port part.

I believe this is a bug.

Thanks,
Nuno

[1] http://nginx.org/en/docs/http/ngx_http_core_module.html


More information about the nginx mailing list