Ghost configuration url doesn't work unless it is set to 'http://localhost'

I have 2 EC2 instances one runs the blog, the other upstreams with nginx to it and serves the blog at

If I put ‘’ the Blog is not accessible from the nginx instance. If I put ‘http://localhost’ it is? Any ideas on what could be happening or where to look for clues?


After trial and error I figured it out.

The default Ghost nginx configuration is:

location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $http_host;

But then in X-Forwarded-Proto $schema will be equal to http, which causes the Ghost to redirect to https thus creating a 301 redirect loop.

Manually setting the X-Forwarded-Proto to https will fix the issue.