I have a nginx reverse proxy on a server where I run a bunch of apps, e.g. app1.domain.com, app2.domain.com, etc. I recently added a new application with the following config (with LetsEncrypt for SSL):
server { server_name app.domain.com; server_name_in_redirect off; location / { proxy_pass proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/ # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/ # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server { if ($host = app.domain.com) { return 301 } # managed by Certbot server_name app.domain.com; listen 80; return 404; # managed by Certbot
}However, whenever I go to it redirects to . What's stranger still is that if I manually fix the url to it loads fine, and if I click around the app to navigate to different paths it correctly stays on app.domain.com. This nginx config is pretty much identical to another app I use so I'm not sure why this one in particular is redirecting like this. At first I thought it was the app thinking it's URL is 127.0.0.1:6767 and redirecting there, but if I try a GET request for in Postman I get Error: connect ECONNREFUSED 127.0.0.1:6767 (which doesn't have the /somelandingpage path) so it makes me think this must be the nginx config. But if that's the case, what am I missing here?