How To Fix The Infinite Redirect Loop With HTTPS, Nginx And Your Ghost Blog

Today I stumbled over few issues with an infinite redirection loop and Ghost. Based on the reported issues I was playing with a local Ghost blog instance and could reproduce the problem.

First, I changed the URL of my local blog instance to HTTPS and after that Nginx run into that known issue. The local domain used a standard Nginx config file and here I could find the problem. The X-Forwarded-Proto value in the proxy_set_header directive had assigned a static http value instead of the dynamic $scheme variable. So I switched the value from proxy_set_header X-Forwarded-Proto https; to proxy_set_header X-Forwarded-Proto $scheme;, restarted the Nginx web server and the redirection issue disappeared.

// just an nginx config example...
server {
    location / {
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto $scheme;
        proxy_set_header        Host $http_host;
        proxy_intercept_errors  on;
        proxy_pass    ;
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn