# Too many redirects - docker + nginx proxy\_pass

**URL:** <https://forum.ghost.org/t/too-many-redirects-docker-nginx-proxy-pass/14522>\
**Category:** Installation\
**Created:** [May 19, 2020, 9:11pm UTC](https://forum.ghost.org/t/too-many-redirects-docker-nginx-proxy-pass/14522 "2020-05-19T21:11:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![samr28](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/samr28/32/8016_2.png) [@samr28](https://forum.ghost.org/u/samr28)\
**Post date:** [May 19, 2020, 9:11pm UTC](https://forum.ghost.org/t/too-many-redirects-docker-nginx-proxy-pass/14522/1 "2020-05-19T21:11:39Z")

</div>

Trying to use docker-compose to run ghost + mysql to host a site. I already have nginx on the host machine (ubuntu 20.04) and I’m trying to use that to pass the ghost site (in docker container).

Everything worked fine over http through the domain but when I used certbot to switch to https, it stopped working with the error: ERR\_TOO\_MANY\_REDIRECTS. I read a lot of similar issues and it seemes like most people were forgetting to pass their headers when doing the proxy\_pass. I made sure to do that as you can see below in my nginx file. I’m guessing theres an issue with the docker side but I’m honestly not sure.

- [https://esk8.us/](https://esk8.us/)

nginx site config file:

```auto
server {

	server_name esk8.us;

	location / {
    		proxy_set_header X-Real-IP $remote_addr;
    		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    		proxy_set_header Host $http_host;
    		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_pass http://localhost:2368;
	}

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/esk8.us/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/esk8.us/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = esk8.us) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

	server_name esk8.us;

    listen [::]:80;
    listen 80;
    return 404; # managed by Certbot

}

```

docker-compose.yml:

```plaintext
version: '3'

services:
  ghost:
    image: ghost:latest
    container_name: ghost
    hostname: ghost
    volumes:
      - ./ghost/content:/var/lib/ghost/content:z
    expose:
      - "3306"
    ports:
      - 2368:2368
    environment:
      - NODE_ENV=production
      - url=https://esk8.us
    restart: always
    links:
      - mysql

  mysql:
    image: mysql:latest
    container_name: mysql-ghost
    volumes:
      - ./dbdata:/var/lib/mysql:z 
    expose:
      - "3306"
    environment:
      - MYSQL_ROOT_PASSWORD=<removed>
      - MYSQL_DATABASE=ghostdata
      - MYSQL_USER=ghostusr
      - MYSQL_PASSWORD=<removed>
    restart: always

```

Chrome network waterfall:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/6/6f7b1a64a6bafcf855770e18e9e9bb37cb9d79ed.png)

---

<div class="post-metadata">

**Author:** ![samr28](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/samr28/32/8016_2.png) [@samr28](https://forum.ghost.org/u/samr28)\
**Post date:** [May 19, 2020, 9:36pm UTC](https://forum.ghost.org/t/too-many-redirects-docker-nginx-proxy-pass/14522/2 "2020-05-19T21:36:50Z")

</div>

Found the solution here: [Bug: Setting url: to https in config.js causes a redirect loop · Issue #2796 · TryGhost/Ghost · GitHub](https://github.com/TryGhost/Ghost/issues/2796#issuecomment-392327647)

I needed to set SSL to full (strict) in Cloudflare!
