I’m currently using ghost cli and I’d like to self host activitypub. I have multiple ghost sites and it looks like migration only helps with a single site. How do I host multiple ghost blogs through docker?
There’s a few ways to get that going, but what I ended up doing last night for a server running two Ghost sites looks like this:
- Set up a Docker Compose stack for each site (make
/opt/siteA,/opt/siteB, follow the setup guide for each, run the migration script) - Assign an additional IPv6 address to the server per additional site
- Bind each Caddy container to a dedicated IPv6 address
- Put a service in front of the server to translate between IPv4/IPv6 (Cloudflare)
The advantage of this setup for me is when changes are made upstream to the compose.yml file, I will only have to worry about the two lines for Caddy.
I wrote a rough overview on accomplishing this with Vultr and Cloudflare here:
Great tip. Thank you!
Could you bind caddy to another port (8080?) and reverse proxy with nginx?
Yes, but why?
Rather than doing that, why not implement the Caddyfile in Nginx?
to be able to keep the official repo with the least changes possibles so we can pull on future updates?
But wouldn’t you need to change the compose file anyway, to bind another port?
Yes. But it is a one line change.
Not saying is the only way but an easy way to get multiple dockers on one server.
You could, and this is what I initially tried (using Caddy instead of Nginx) but I ran out of time to get it working. Kept downloading an empty file instead of loading the site lol. Using Nginx makes sense if you’ve got sites installed with Ghost CLI and want a hybrid setup while you migrate.
I tried a few different setups for my two sites: one was a reverse proxy to the Caddy containers running on different ports, another was dropping the ports directive for expose and running a reverse proxy Caddy container on both Docker networks, and the last one was disabling the bundled Caddy containers and pointing the reverse proxy Caddy container directly at the Ghost containers. All three should work in theory, though I prefer the IPv6 method if available.
If you get it working please share an example of your config ![]()
Yes, those are nice solutions as well.
I do have this working, not with this docker just yet but with many other dockers on the same server.
The idea is to leave the docker as it is, change the port that caddy is using and setup a nginx reverse proxy on the server (not inside docker) that is used to redirect the request from each domain to the port of each docker.
With this you could also use static cache and other configurations (I have antibots and firewalls on my nginx setups) without modifying the caddy files.
WIth cache and 2 sites it could look something like this.
# Cache zones - one per site
proxy_cache_path /var/cache/nginx/site1 keys_zone=site1_cache:10m max_size=200m;
proxy_cache_path /var/cache/nginx/site2 keys_zone=site2_cache:10m max_size=200m;
# Site 1 - domain1.com
server {
server_name domain1.com;
location / {
proxy_pass http://127.0.0.1:8080; # Your Ghost+Caddy stack
proxy_cache site1_cache;
}
}
# Site 2 - domain2.com
server {
server_name domain2.com;
location / {
proxy_pass http://127.0.0.1:8081; # Different container
proxy_cache site2_cache;
}
}
Or using upstream
upstream caddy_backend {
server 127.0.0.1:8443; # HTTPS to Caddy
keepalive 32;
}
# And use https in proxy_pass
proxy_pass https://caddy_backend;
Those are not live code, do not use it like this on your projects, it is just an example.
Thanks for the guide, helpful since I also sometimes use Vultr, and always Cloudflare.
One thing to point out in the opening of your guide:
Ghost 6.0 comes with official Docker tooling to use instead of the CLI. It’s required if you want the ActivityPub features.
It’s the new Tinybird analytics feature that requires Docker, not ActivityPub. ActivityPub works for Ghost-CLI installs, it just has some limits Happy Ghost 6.0 Day 🎉! Quick question - #2 by Hannah
I actually sat down to give this a try and I got a 521 error. Do you know how to get past this?