coronastatus icon indicating copy to clipboard operation
coronastatus copied to clipboard

Redirect loop when nginx does not forward protocol scheme

Open michaelmcmillan opened this issue 5 years ago • 2 comments

server {
    server_name coronastatus.fr www.coronastatus.fr;

    location / {
        proxy_pass http://127.0.0.1:5000;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme; <-- Must be added
    }

    error_page 502 /502.html;
    location = /502.html {
      root  /var/www/html;
    }
    error_page 401 /401.html;
    location = /401.html {
      root  /var/www/html;
    }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/coronastatus.fr/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/coronastatus.fr/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

michaelmcmillan avatar Mar 26 '20 15:03 michaelmcmillan

I'm getting a "too many redirects" error, and am wondering if this might be the cause. I already reported this on Twitter. Subscribing here so I can try again when something changes on your end.

aolieman avatar Mar 27 '20 10:03 aolieman

@zerbfra

michaelmcmillan avatar Mar 27 '20 10:03 michaelmcmillan