Title here
Summary here
Short example how to get multiple Ghost CMS instances running in front of a single Caddy Webserver.
The key in this example is to use the domain name as the name of the docker-compose folder:
├── example.com
│ └── compose.yml
├── example.org
│ └── compose.yml
├── example.net
│ └── compose.yml
└── webserver
├── compose.yml
└── conf
└── CaddyfileIn Caddy’s compose.yml we reference those domains as variables:
---
environment:
FROM_IP: 'w.x.y.z/32'
DOMAIN_1: example.com
DOMAIN_2: example.org
DOMAIN_3: example.net
networks:
# DOMAIN_1
- examplecom_default
# DOMAIN_2
- exampleorg_default
# DOMAIN_3
- examplenet_default
networks:
# DOMAIN_1
examplecom_default:
external: true
# DOMAIN_2
exampleorg_default:
external: true
# DOMAIN_3
examplenet_default:
external: trueNow in each Ghost compose.yml we disable ports: and adding container_name: with our domain name to enable this name as a DNS address inside of the docker network:
---
services:
ghost:
image: ghost:6.9.1
restart: always
# ports:
# - 8080:2368
container_name: example.comFinally in Caddy’s config we adding the target domains as variables:
{$FROM_IP} = allowed to access /ghost{$DOMAIN_1}= referenced as domain and reverse_proxy target{$DOMAIN_1} {
reverse_proxy {$DOMAIN_1}:2368
log {
output file /log/{$DOMAIN_1}.log
}
@denied {
not remote_ip {$FROM_IP}
path /ghost/*
}
abort @denied
}
{$DOMAIN_2} {
reverse_proxy {$DOMAIN_2}:2368
log {
output file /log/{$DOMAIN_2}.log
}
@denied {
not remote_ip {$FROM_IP}
path /ghost/*
}
abort @denied
}
{$DOMAIN_3} {
reverse_proxy {$DOMAIN_3}:2368
log {
output file /log/{$DOMAIN_3}.log
}
@denied {
not remote_ip {$FROM_IP}
path /ghost/*
}
abort @denied
}