Moved Permanently. Redirecting to https://XXXXX

Hi, I am currently running ghost on docker, with a load balancer in front of it, and I get this issue which I don’t understand:

ubuntu@qcloud:~/data/compose/ghost$ curl
Moved Permanently. Redirecting to https://ghost/
the following is the my settings of everything

Ghost Version: docker image: ghost:1-alpine

Ghost compose file:

image: ghost:1-alpine
restart: always
- 2368:2368
- ~/data/docker_volumes/ghost/content:/var/lib/ghost/content
- url=

Nginx compose file:

image: nginx
- “80:80”
- “443:443”
- ./certs:/etc/nginx/certs
- ./conf.d/

Nginx conf:

upstream ghost {
server {
listen 80;
return 301 https://$host$request_uri;
server {

listen 443 ssl http2;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/nginx/certs/;
ssl_certificate_key /etc/nginx/certs/;

client_max_body_size 0;

location / {
	proxy_pass http://ghost;


PS: if I remove url environment variable, it goes right,
- url=
but the blog site does not handle links right.

If you are running multiple instances of Ghost for the same blog that won’t work. From the install docs:

You’re nginx config is not passing the necessary headers through to Ghost so it won’t know what URL it’s serving. Ghost-CLI is the recommended/supported way to install Ghost, it has nginx templates that you should follow if installing your own way.

according to docker-compose.yml of ghost, it runs just 1 instance. and the url nerver changed.

You’re good on the multi-instance side of things then but you’ll still need to fix your nginx config for Ghost to work correctly.

after I added the following headers from templete nginx file to conf
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;
nothing changes

thanks anyway

Just to be sure, check where the node.js port is listening to, as well as your blog sudo netstat -peanut

Also why are you proxying to
Try changing that to:


where 2368 is the port where node is running or put whichever server you’re using

nginx is not on the same node which blog is deployed. nginx is deployed in USA, but blog is deployed in China, I am sure the blog is accessable, because if url is not set in the environment, redirect is successful.
proxy_pass http://ghost;
above line is just pointing to the upstream:
upstream ghost {

Looks like I’m having related issue:

i.e. when i change the http to https in the json config (url variable) i see the same Moved Permanently status and infinite redirect loop in Chrome.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.