# Moved Permanently. Redirecting to https://XXXXX

**URL:** <https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336>\
**Category:** Developer help\
**Created:** [August 9, 2018, 9:02am UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336 "2018-08-09T09:02:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![linxyfe](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@linxyfe](https://forum.ghost.org/u/linxyfe)\
**Post date:** [August 9, 2018, 9:02am UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336/1 "2018-08-09T09:02:37Z")

</div>

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 [https://blog.xoxox.io](https://blog.xoxox.io)  
Moved Permanently. Redirecting to [https://ghost/](https://ghost/)  
the following is the my settings of everything

Ghost Version: docker image: ghost:1-alpine

Ghost compose file:

blog:  
image: ghost:1-alpine  
restart: always  
ports:  
- 2368:2368  
volumes:  
- ~/data/docker\_volumes/ghost/content:/var/lib/ghost/content  
environment:  
- [MAIL\_FROM=will@xoxox.io](mailto:MAIL_FROM=will@xoxox.io)  
- url=[https://blog.xoxox.io](https://blog.xoxox.io)

Nginx compose file:

proxy:  
image: nginx  
ports:  
- “80:80”  
- “443:443”  
volumes:  
- ./certs:/etc/nginx/certs  
- ./conf.d/blog.xoxox.io.conf:/etc/nginx/conf.d/blog.xoxox.io.conf

Nginx conf:

upstream ghost {  
server [qcloud.xoxox.io:2368](http://qcloud.xoxox.io:2368);  
}  
server {  
server\_name [blog.xoxox.io](http://blog.xoxox.io);  
listen 80;  
return 301 https://$host$request\_uri;  
}  
server {  
server\_name [blog.xoxox.io](http://blog.xoxox.io);

```
listen 443 ssl http2;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/nginx/certs/blog.xoxox.io.crt;
ssl_certificate_key /etc/nginx/certs/blog.xoxox.io.key;

client_max_body_size 0;

location / {
	proxy_pass http://ghost;
}

```

}

PS: if I remove url environment variable, it goes right,  
- url=[https://blog.xoxox.io](https://blog.xoxox.io)  
but the blog site does not handle links right.

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [August 9, 2018, 9:07am UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336/2 "2018-08-09T09:07:00Z")

</div>

> [@linxyfe](#):
>
> I am currently running ghost on docker, with a load balancer in front of it,

If you are running multiple instances of Ghost for the same blog that won’t work. From [the install docs](https://docs.ghost.org/docs/install):

 ![40](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/9/97811891cde728527ace135668ae9d463fced9eb.png)

> [@linxyfe](#):
>
> Nginx conf:

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](https://github.com/TryGhost/Ghost-CLI) is the recommended/supported way to install Ghost, it has [nginx templates](https://github.com/TryGhost/Ghost-CLI/blob/master/extensions/nginx/templates/) that you should follow if installing your own way.

---

<div class="post-metadata">

**Author:** ![linxyfe](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@linxyfe](https://forum.ghost.org/u/linxyfe)\
**Post date:** [August 9, 2018, 9:12am UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336/3 "2018-08-09T09:12:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/kevin/32/32_2.png) [@Kevin](https://forum.ghost.org/u/Kevin)\
**Post date:** [August 9, 2018, 9:13am UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336/4 "2018-08-09T09:13:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![linxyfe](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@linxyfe](https://forum.ghost.org/u/linxyfe)\
**Post date:** [August 9, 2018, 9:29am UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336/5 "2018-08-09T09:29:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![linxyfe](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@linxyfe](https://forum.ghost.org/u/linxyfe)\
**Post date:** [August 9, 2018, 9:30am UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336/6 "2018-08-09T09:30:17Z")

</div>

thanks anyway

---

<div class="post-metadata">

**Author:** ![afern247](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/afern247/32/10894_2.png) [@afern247](https://forum.ghost.org/u/afern247)\
**Post date:** [August 9, 2018, 12:24pm UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336/7 "2018-08-09T12:24:25Z")

</div>

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 [ghost.org](http://ghost.org)?  
Try changing that to:

```auto
proxy_pass http://127.0.0.1:2368;  

```

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

---

<div class="post-metadata">

**Author:** ![linxyfe](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@linxyfe](https://forum.ghost.org/u/linxyfe)\
**Post date:** [August 10, 2018, 3:15am UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336/8 "2018-08-10T03:15:25Z")

</div>

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](http://ghost);  
above line is just pointing to the upstream:  
upstream ghost {  
server [qcloud.xoxox.io:2368](http://qcloud.xoxox.io:2368);  
}

---

<div class="post-metadata">

**Author:** ![zeppelinux](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/zeppelinux/32/1176_2.png) [@zeppelinux](https://forum.ghost.org/u/zeppelinux)\
**Post date:** [August 10, 2018, 7:33pm UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336/9 "2018-08-10T19:33:12Z")

</div>

Looks like I’m having related issue: [https://forum.ghost.org/t/http-x-forwarded-proto-not-used-by-all-requests](https://forum.ghost.org/t/http-x-forwarded-proto-not-used-by-all-requests)

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/b/ba9ce5100b8bb264586f4f572545596b2ce3f081.png) [@system](https://forum.ghost.org/u/system)\
**Post date:** [August 24, 2018, 7:33pm UTC](https://forum.ghost.org/t/moved-permanently-redirecting-to-https-xxxxx/2336/10 "2018-08-24T19:33:22Z")

</div>

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