Digital Sovereign Ghost
Phoenix Paulina Schmid @posts@blog.gelbphoenix.de
Ghost is a wonderful blogging and publishing platform and running a modern blog of your own is more than just putting a Content Management System on a VPS or using a dedicated provider. It is a constant commitment to digital sovereignty, data ownership and minimal dependencies on foreign cloud providers.
When Ghost released its 6.0 version, it introduced a native analytics feature that relies upon the New York-based Tinybird for cookie-free, real-time data processing. And by default the documentation steers admins of self-hosted Ghost instances (servers) to sign up for a free Tinybird account for the cloud-based offering. The free offering is good for small and medium blogs but does run on the cloud infrastructure of Google and/or Amazon.
This is exactly the point that feels like a compromise of the very principles that led me to self-host in the first place and made me look for a way to bring that dependency under my own control.
My attempt to move to Tinybird Local
Tinybird offers two ways to self-host its infrastructure, Tinybird Self-Managed Regions and Tinybird Local. The former is aimed at enterprise-scale deployments with the resources that implies, whereas the latter is designed for development.
But with the right configuration and a robust reverse proxy the Tinybird Local container can function as a lightweight, permanent backend for Ghost Analytics on a self-hosted Ghost instance.
I tested this on the night from the 6 to 7 June 2026. Since you are reading this version of the post, it worked: the analytics of this blog now use the Tinybird Local container instead of the cloud offering.
What is running under the hood
We need to look at what Tinybird Local is to understand how this works. It's a streaming data platform built on ClickHouse – a database designed for analytics data.
When you spin up the tinybird-local container you are essentially starting a lightweight Tinybird workspace but contained in a single container.
Here is how the data flows in this self-hosted ecosystem:
- The Reader: Someone visits the blog. Ghost's native tracking script sends an event.
- Caddy: Intercepts the analytics traffic and securely routes it to the local infrastructure.
- Tinybird Local: Ingests the raw event stream, validates it, and efficiently stores and aggregates the analytics data.
- Ghost Dashboard: Queries the local Tinybird API to display your real-time visitor stats.
If you like this blog post you can support my work by either becoming a paid member or leaving a tip.
Making it Work
To transition your analytics backend from the cloud offering to a deployed instance of Tinybird Local you need Ghost running via Docker and a server with at least 8 GB of RAM. Then do the following:
Docker Compose
We can simply add the following configuration to the compose.yml with which we run Ghost:
tinybird-local:
image: tinybirdco/tinybird-local:latest
container_name: tinybird-local
restart: unless-stopped
ports:
- "127.0.0.1:7181:7181"
volumes:
- ./data/tb_local/clickhouse:/var/lib/clickhouse
- ./data/tb_local/redis:/redis-data
profiles: [analytics]
networks:
- proxy
deploy:
resources:
limits:
cpus: '6.0' # Set this to your needs
memory: 4096M
reservations:
memory: 2048M
healthcheck:
test: ["CMD", "curl", "-fsS", "http://localhost:7181"]
interval: 5s
timeout: 5s
retries: 30
tinybird-sync:
# Do not alter this without updating the Ghost container as well
image: ghost:${GHOST_VERSION}
container_name: tinybird-sync
command: >
sh -c "
if [ -d /var/lib/ghost/current/core/server/data/tinybird ]; then
rm -rf /data/tinybird/*;
cp -rf /var/lib/ghost/current/core/server/data/tinybird/* /data/tinybird/;
echo 'Tinybird files synced into shared volume.';
else
echo 'Tinybird source directory not found.';
fi
"
volumes:
- ./data/tinybird/files:/data/tinybird
depends_on:
tinybird-local: # Add this
condition: service_healthy # Add this
tinybird-login:
condition: service_completed_successfully
networks:
- proxy
profiles: [analytics]
restart: no
tinybird-deploy:
build:
context: ./tinybird
dockerfile: Dockerfile
container_name: tinybird-deploy
working_dir: /data/tinybird
command: >
sh -c '
for i in $(seq 1 20); do
if tb-wrapper --cloud deploy -v; then
exit 0
fi
echo "Tinybird deploy not ready yet, retrying in 5s..."
sleep 5
done
exit 1
' # Changed: the original is just "tb-wrapper --cloud deploy", this adds a retry loop and -v
volumes:
- ./data/tinybird/home:/home/tinybird
- ./data/tinybird/files:/data/tinybird
depends_on:
tinybird-sync:
condition: service_completed_successfully
profiles: [analytics]
networks:
- proxy
tty: trueCaddy
Allowing Ghost to talk to the Tinybird Local container requires that we add the following to the Caddyfile. Replace DOMAIN with your own domain.
# Tinybird for Ghost
tinybird.DOMAIN {
@tinybird_admin {
path /tokens*
not remote_ip 127.0.0.1 ::1
}
respond @tinybird_admin "Forbidden" 403
reverse_proxy 127.0.0.1:7181
}Environment file
After starting the tinybird-local container for the first time, we can look up the tokens via the http://localhost:7181/tokens URL and change (or add) the respective tokens and the URL to the .env file. Don't forget to also change the .tinyb file in the subdirectories of data/tinybird.
The .env file should look something like this:
TINYBIRD_API_URL=https://tinybird.DOMAIN
TINYBIRD_WORKSPACE_ID=00000000-0000-0000-0000-000000000001
TINYBIRD_ADMIN_TOKEN=p.eyJ1IjogIjAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMSIsICJpZCI6ICJhZG1pbiJ9.example_admin_token_value
TINYBIRD_TRACKER_TOKEN=p.eyJ1IjogIjAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMSIsICJpZCI6ICJ0cmFja2VyIn0.example_tracker_token_valueSecuring your own digital sovereignty isn't always easy. It sometimes requires peeking behind or around official documentation and occasionally repurposing tools to serve production needs.
By moving the analytics of self-hosted Ghost instances out of the cloud, we eliminate a major point of external surveillance and take responsibility for the data privacy of the readers of our blog and members of our communities.
Would you – if you have a Ghost-based blog – switch your analytics backend or stay with whatever you have? Let's discuss! 📝
If you want to hear more from me, you can find me in the Fediverse at @gelbphoenix@social.gelbphoenix.de (Mastodon) or @gelbphoenix@gram.social (Pixelfed). For more posts like this subscribe to my newsletter or support me by becoming a member or donating.
Liked this post? Please share it with others via: Mastodon, Bluesky or anywhere else by copying the link.