Deployn

Guide for Ghost CMS behind Traefik

In this short tutorial I will show you how to get the CMS Ghost running behind a Traefik proxy.

Guide for Ghost CMS behind Traefik-heroimage

CAUTION

Please note that this blog post was originally written in German and has been translated for your convenience. Although every effort has been made to ensure accuracy, there may be translation errors. I apologize for any discrepancies or misunderstandings that may result from the translation and I am grateful for any corrections in the comments or via mail.

Content management systems are essential, for example, to create a blog. Still, the authors want to avoid creating HTML or Markdown files.

The most popular CMS is WordPress, according to Statista, with a share of 64%. In 2021, over 30% of all websites will run on WordPress. It is probably so popular because it is easy to use and has many extensions. However, there are also many other content management systems.

Ghost - Just A Blogging Platform

I would like to use Ghost here. Ghost was once advertised as a pure blogging platform, but it has come a long way (both positively and negatively). Ghost uses Node.js and is generally faster than WordPress. It is also possible to use Ghost (like WordPress) headless if required. The open-source software can also be extended with many plugins. An important feature is the powerful visual editor with familiar formatting options and the ability to seamlessly add dynamic content.

Ghost: Turn your audience into a business
The world’s most popular modern publishing platform for creating a new media platform. Used by Apple, SkyNews, Buffer, OpenAI, and thousands more.
Ghost.org

Ghost - The Professional Publishing Platform

Install Ghost CMS

A server with Docker is required. Here I assume that Traefik has been installed as a proxy manager, as described in my other guide.

The installation can be started after the connection to the server has been established, ssh username@server-ip.

cd ~/docker
mkdir appdata/ghost
mkdir appdata/ghost/content
mkdir appdata/ghost/db
nano .env

We enter a new line in the file with GHOST_DB_PASSWORD=securepassword. Then we create a new docker-compose file with nano docker-compose-ghost.yml.

I don’t want to use the built-in SQLite database; I want to create a separate database. Thanks to Traefik, the connection is pretty simple.

version: "3.7"

### NETWORKS ###
networks:
    web:
        external:
            name: web
    ghost-internal:
        external: false
    default:
        driver: bridge

### SERVICES ###
services:
    ghost:
        container_name: ghost
        image: ghost:latest
        restart: unless-stopped
        networks:
            - ghost-internal
            - web
        security_opt:
            - no-new-privileges:true
        environment:
            - database__client=mysql
            - database__connection__host=ghost-db
            - database__connection__user=root
            - database__connection__password=$GHOST_DB_PASSWORD
            - database__connection__database=ghost
            - url=https://ghost.$DOMAINNAME
        volumes:
            - $DOCKERDIR/appdata/ghost/content:/var/lib/ghost/content
        labels:
            - "traefik.enable=true"
            - "traefik.http.routers.ghost-rtr.entrypoints=https"
            - "traefik.http.routers.ghost-rtr.rule=Host(`ghost.$DOMAINNAME`)"
            - "traefik.http.routers.ghost-rtr.tls=true"
            - "traefik.http.routers.ghost-rtr.service=ghost-svc"
            - "traefik.http.services.ghost-svc.loadbalancer.server.port=2368"
            - "traefik.http.routers.ghost-rtr.middlewares=chain-no-auth@file"
        depends_on:
            - ghost-db

    ghost-db:
        container_name: ghost-db
        image: mariadb:latest
        restart: unless-stopped
        networks:
            - ghost-internal
        security_opt:
            - no-new-privileges:true
        environment:
            - MYSQL_ROOT_PASSWORD=$GHOST_DB_PASSWORD
        volumes:
            - $DOCKERDIR/appdata/ghost/db:/var/lib/mysql
        labels:
            - "traefik.enable=false"

Attention: The functions with the memberships can not be switched off since version 4, depending on the type of use this could be questionable in terms of data protection. It is possible to either switch to a version with image: ghost:3 instead of ghost:latest or to use a theme that does not support the functionality.

Update: From version 4.4 the functionality is integrated again 😀

Access settings in the Ghost Dashboard

The container can be started via docker-compose -f docker-compose-ghost.yml up -d. The admin account can be set up under “ghost.domain.de/ghost”. In the settings, the site can also be set to private and thus provided with a password. Password for entire site

Update Ghost

If a new release of Ghost (the following applies not only to Ghost, but to all containers) is provided, this can also be updated relatively quickly.

cd ~/docker
lazydocker

In Lazydocker I can see my Ghost image under Images.

Ghost:latest from April 11

The image is no longer the latest. I stop the ghost container, load the latest image and start the ghost container.

docker-compose -f docker-compose-ghost down
docker pull ghost
docker-compose -f docker-compose-ghost up -d

The update is now complete. Newer image


This website uses cookies. These are necessary for the functionality of the website. You can find more information in the privacy policy