Nginx Loses Port on Redirect
Solution 1:
The default proxy_redirect
when using a proxy_pass
inside a location
(adapted to your use case) is:
location / {
proxy_pass http://localhost:8080/;
proxy_redirect http://localhost:8080/ /;
}
Since you are using the same 8080 port in Vagrant, this will match and remove the port.
There are two easy solutions to avoid this:
- Forward to a different port in the vagrant configuration so that
proxy_redirect
doesn't match. - Disable
proxy_redirect
usingproxy_redirect off;
.
(I know this was 4 years ago, but I just had a similar problem while testing KeyCloak, so I hope this answer helps others that face this problem.)