There's a special case where a proxy_pass
with a location
ending in /
would result in an automatic implicit 301
redirect without going to the backend; you have to create an explicit location
without the trailing slash to avoid this:
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:
location /user/ {
proxy_pass http://user.example.com;
}
location = /user {
proxy_pass http://login.example.com;
}
E.g., you gotta create an explicit /pass
location
in addition to the existing /pass/
one, otherwise, an implicit location /pass {return 301 /pass/…;}
will be created for you.
However, are you sure you actually want to do what you're trying to do? If you're going to omit a redirect from /pass
to /pass/
, then relative paths aren't going to work. Some newer browsers also have a tendency to feature defective UI/UX that may not present the trailing slash to the user, which may make things even more confusing when trying to troubleshoot the distinction.