I want to redirect localhost request to HTTPS. This is what my .conf looks like:
server {
listen 80;
listen 443 ssl;
ssl_certificate /etc/ssl/localhost.crt;
ssl_certificate_key /etc/ssl/localhost.key;
server_name localhost;
return 301 https://$server_name$request_uri;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
I run this in a Docker container with -p 80:80 -p 443:443
but calling the server from the browser results in a loop of https://localhost/
calls.