Hi I have nginx setup to redirect all port 80 requests to use https instead:
server {
listen 80;
...
return 301 https://$host$request_uri;
}
Then I have all https requests route to my application server
server {
listen 443 ssl;
...
location / {
proxy_pass http://localhost:8080;
proxy_redirect off;
...
}
}
All working as expected except those 302 responses with a Location
header (e.g. Location: http://localhost/somepage
), I would expect them to be redirected to use https (as they are accessing pages via port 80), however, I got an error (net::ERR_FAILED) instead. Strangely, directly typing those URLs in browser (e.g. http://localhost/somepage) works as expected (i.e. redirected to use https and page returns), so only the Location
URLs are not being redirected by nginx, please help.