I have 2 EC2 instances one runs the blog, the other upstreams with nginx to it and serves the blog at https://blog.domain.com.
If I put ‘https://blog.domain.com’ 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?
Thanks!
Ivo
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;
proxy_pass http://127.0.0.1:2368;
}
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.