How to set up: ghost CMS + Docker + Cloudflare without strict ssl enabled

Fixing error - HTTPS and ERR_TOO_MANY_REDIRECTS

How to set up: ghost CMS + Docker + Cloudflare without strict ssl enabled

Pre-requirements:

  1. Server with installed some Linux OS(I'm using Debian 11)

  2. Installed docker + docker-compose

  3. Installed Nginx

  4. Domain registered on Cloudflare

Steps to set up:

  1. Cloudflare - almost nothing

  2. Create docker-compose.yaml on your server and copy content from here - https://hub.docker.com/_/ghost/ (docker-compose.yaml block)

version: '3.1'

services:

  ghost:
    image: ghost:5-alpine
    restart: always
    ports:
      - 2368:2368
    environment:
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: example
      database__connection__database: ghost
      url: https://blog.vladverpeta.com
    volumes:
      - ghost:/var/lib/ghost/content

  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example
    volumes:
      - db:/var/lib/mysql

volumes:
  ghost:
  db:

PS: Dont forgot setup firewall that will restrict any connections to your server except: 80, 22, 433 ports

  1. Run docker-compose up -d

  2. Edit/create - /etc/nginx/sites-enabled/{your-blog.com}

server {
    listen 80;
    server_name blog.vladverpeta.com;

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

Put eyes on lines 7 and 10, without them, you will have TOO_MANY_REDIRECTS error.

  1. Run nginx -s reload to apply changes in nginx.

That's all, I hope it works for you!)

Don't hesitate to contact me - I'll try to help you🤓