Configuration files for self-hosting n8n using Docker and Cloudflare Tunnel.
- Domain managed by Cloudflare
- Docker and Docker Compose installed
- Cloudflared CLI installed (
brew install cloudflaredon macOS) - Cloudflare account
docker-compose up -dFirst, create your config.yml file from the example:
cp config.yml.example config.ymlThen edit config.yml and replace the placeholders:
- Replace
YOUR_TUNNEL_NAMEwith your tunnel name (e.g.,n8n) - Replace
YOUR_TUNNEL_IDwith your actual tunnel ID (you'll get this after creating the tunnel) - Replace
YOUR_SUBDOMAIN.YOUR_DOMAIN.comwith your actual hostname (e.g.,n8n.example.com)
Authenticate with Cloudflare:
cloudflared tunnel loginCreate the tunnel:
cloudflared tunnel create n8nAfter creating the tunnel, update config.yml with the correct
credentials-file path. The tunnel ID will be in the filename of the
credentials file created in ~/.cloudflared/ (e.g.,
~/.cloudflared/513686a1-6a7b-42a8-b36e-61f8d7e08409.json).
Route DNS (replace YOUR_TUNNEL_NAME and YOUR_SUBDOMAIN.YOUR_DOMAIN.com with
your actual values):
cloudflared tunnel route dns YOUR_TUNNEL_NAME YOUR_SUBDOMAIN.YOUR_DOMAIN.comIf the automated DNS route command fails, manually create a DNS record in Cloudflare:
- Go to Cloudflare Dashboard
- Select your domain
- Go to DNS → Records
- Click Add record:
- Type:
CNAME - Name:
n8n(or your desired subdomain) - Target:
<your-tunnel-id>.cfargotunnel.com(replace<your-tunnel-id>with your actual tunnel ID) - Proxy status: Proxied (orange cloud)
- Click Save
- Type:
Start the tunnel:
cloudflared tunnel --config config.yml runTo run in the background:
cloudflared tunnel --config config.yml run &Note: The tunnel must be running for your n8n instance to be accessible.
To keep it running permanently, set it up as a system service or use a process
manager like screen or tmux.
Access n8n at: https://YOUR_SUBDOMAIN.YOUR_DOMAIN.com (replace with your actual hostname)
For more details, see: http://jeffbailey.us/blog/2025/11/21/how-do-i-self-host-n8n