Below is my current nginx config.
server {
listen 80 default_server;
server_name _;
return 307 https://$host$request_uri;
}
server {
listen [::]:443 ssl;
listen 443 ssl;
server_name localhost;
# Protect against the BEAST attack by not using SSLv3 at all. If you need to support older browsers (IE6) you may need to add
# SSLv3 to the list of protocols below.
ssl_protocols TLSv1.2;
ssl_certificate /etc/nginx/ssl.crt;
ssl_certificate_key /etc/nginx/ssl.key;
location / {
proxy_pass http://localhost:80; # TODO: replace port if app listens on port other than 80
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
All has been working well, but I recently added the first 'server' block hoping to redirect my url to https:// whenever a http:// version of the URL is visited, but I am getting an 'ERR_TOO_MANY_REDIRECTS' message when visiting the URL in the browser.
My application's port is on 80 within an Azure Container.
Any help would be appreciated!