Self-hosted n8n exposed through a Cloudflare Tunnel — no ports forwarded on the router.
The public hostname is configured via N8N_HOST in .env.
- n8n: Workflow automation platform (port 5678)
- PostgreSQL 15: n8n database
- Cloudflare Tunnel: Traffic proxying from
$N8N_HOSTto n8n - Docker Compose: Container orchestration
- Redis: running, but
⚠️ not actually used — see below
An earlier version of this README claimed Redis was the queue backend and that a separate n8n worker executed jobs from it. Neither is true:
- there is no
n8n-workerservice indocker-compose.yml; - the
n8nservice sets neitherEXECUTIONS_MODE=queuenor anyQUEUE_BULL_REDIS_*.
So executions run in regular mode, inside the main n8n container. Redis starts, holds an AOF volume and consumes resources without anything connecting to it.
Pick a direction before relying on either: add queue mode plus a worker service,
or drop Redis entirely and delete the redis_data volume.
- Docker and Docker Compose
.envfile with environment variablescloudflared/credentials.jsonfile with Cloudflare credentials
cp .env.example .env
# then fill in real valuesSee .env.example for the full list of variables and what they do.
.env is gitignored; in CI the whole file is stored as the ENV_FILE repository
secret and written out by the workflow before ./start.sh runs.
N8N_BASIC_AUTH_* are leftovers: basic auth was removed in n8n 1.x, so these
are most likely ignored and access is governed by n8n's built-in user management.
Verify how the instance is actually protected before assuming it is closed.
# Copy from your Cloudflare dashboard
cp ~/.cloudflared/credentials.json cloudflared/credentials.json./start.sh./stop.shdocker compose psdocker run --rm -v n8n_data:/data -v $(pwd):/backup alpine tar czf /backup/n8n_backup.tar.gz -C /data .docker run --rm -v n8n_data:/data -v $(pwd):/backup alpine tar xzf /backup/n8n_backup.tar.gz -C /data# If you have existing n8n_data/ folder, run this once:
docker run --rm -v n8n_data:/dest -v $(pwd)/n8n_data:/src alpine cp -a /src/. /dest/After startup, n8n is available at https://$N8N_HOST (the value set in .env).
project_root/
├── cloudflared/
│ ├── config.yml # Cloudflare Tunnel configuration (not in git)
│ ├── config.yml.template # Cloudflare Tunnel configuration template
│ └── credentials.json # Credentials (not in git)
├── docker-compose.yml # Docker Compose configuration
├── start.sh # Start script
├── stop.sh # Stop script
└── .env # Environment variables (not in git)
Docker volumes:
└── n8n_data # n8n persistent data (Docker named volume)
└── postgres_data # Postgres persistent data
└── redis_data # Redis persistent data (AOF)
- n8n data is saved in Docker named volume
n8n_data(persistent across deployments) - Make sure
.envandcredentials.jsonfiles are not committed to git - n8n is configured with basic authentication and HTTPS protocol