I'm sorry for the beginner question but I've spent a long time trying to get this to work properly with no luck.
I have a location block to redirect https://my.domain.com/foo to https://192.168.1.25, which hosts a webapp. When you get to the webapp, the webapp automatically redirects you to https://192.168.1.25/login to log in. When typing in the local IP (https://192.168.1.25) this redirect happens as expected.
When I visit https://my.domain.com/foo, it redirects to https://my.domain.com/login instead of https://my.domain.com/foo/login and I cannot figure out why. This leads to a 404 error.
Here is the relevant section of my nginx.conf file:
server {
listen 80;
server_name my.domain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name my.domain.com;
include ssl_my_domain.conf;
location /foo/ {
proxy_pass https://192.168.1.25/;
}
}
As far as I'm aware, setting trailing slashes in the location block (/foo/ and 192.168.1.25/) should work (as in the responses in Nginx Redirect via Proxy, Rewrite and Preserve URL and elsewhere) but it's just not redirecting properly.
Any help is appreciated.