Configuration of official ghost docker image to server under http://myurl/blog with the help of nginx

Hello everyone —
I am using official ghost docker image for my blog, which i wanted it to be served under http://my-url.com/blog with nginx as reverse proxy. The nginx proxy configuration as follows

server {

	listen 80 default_server;
	
	server_name my-url.com;
	
	location / {
		rewrite ^/(.*) /$1 break;
		proxy_set_header X-Real-IP  $remote_addr;
		proxy_set_header X-Forwarded-For $remote_addr;
		proxy_set_header Host $host;
		proxy_pass http://web:80;
	}
	
	location /blog {
		rewrite ^/blog(.*) /$1 break;
		proxy_set_header X-Real-IP  $remote_addr;
		proxy_set_header X-Forwarded-For $remote_addr;
		proxy_set_header Host $host;
		proxy_pass http://blog:2368;
	}

}

and i am using docker compose to runs my services . The docker-compose file looks like this

version: '3.2'

services: 
        web:
                build: portal
                container_name: app
                networks:
                        - proxy
                volumes:
                        - ./assets:/usr/share/nginx/html/assets/
                ports:
                        - "9000:80"
        
        blog:
                image: ghost:2-alpine
                container_name: blog
                networks:
                        - proxy
                volumes:
                        - /opt/blog:/var/lib/ghost/content
                        - ./config.production.json:/var/lib/ghost/config.production.json
                ports:
                        - "9002:2368"
                environment:
                        NODE_ENV: production

        proxy:
                build: proxy
                container_name: proxy
                networks:
                        - proxy
                ports:
                        - "80:80"

networks:
        proxy:
           external: true

and my config.production.json file looks like

{
  "url": "http://my-url.com/blog",
  "server": {
    "port": 2368,
    "host": "0.0.0.0"
  },
  "database": {
    "client": "sqlite3",
    "connection": {
      "filename": "/var/lib/ghost/content/data/ghost.db"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  }
}

when i visit my page the i get the following error cannot GET /. I barely have no clue why this is happening and was also unable to find any solutions for it. Some help or suggestion would be much appreciated.

Thank you.

Just to make sure you realise: There is no official ghost docker image. The docker image hosted on docker hub is an unofficial community project which is not maintained by the Ghost core team. It works fine, but is generally several versions behind and less stable than other installation methods.

Thanks for the information @John . Can your team or you help me out with my issue

Need nginx logs and possibly the ghost container logs to make sense of why you’re getting the error. I don’t think anyone here can even guess what is causing the resulting error without logs.

These are the logs that are thrown when i try to access my blog

ctm-proxy | 49.249.251.102 - - [07/Dec/2018:08:02:01 +0000] "GET /blog/ HTTP/1.1" 404 140 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" "-"
ctm-proxy | 49.249.251.102 - - [07/Dec/2018:08:02:17 +0000] "GET /blog HTTP/1.1" 404 139 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" "-"
ctm-proxy | 49.249.251.102 - - [07/Dec/2018:08:02:25 +0000] "GET /blog HTTP/1.1" 404 139 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" "-"

where ctm-proxy is my proxy service name .

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