Install n8n (Self‑Hosted)
This guide covers a pragmatic self‑hosted n8n setup using Docker that balances reliability, security, and cost.
Prerequisites
- Docker Engine and Docker Compose
- A reverse proxy (e.g., Nginx, Traefik) for TLS
- Persistent storage for workflows and credentials
Minimal Compose Template
services:
n8n:
image: n8nio/n8n:latest
restart: unless-stopped
environment:
- N8N_HOST=automation.example.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- N8N_ENCRYPTION_KEY=change_me
- WEBHOOK_URL=https://automation.example.com/
ports:
- "5678:5678"
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
Persistence & Backups
- Use named volumes or bind mounts for
/home/node/.n8n - Snapshot the volume periodically and before upgrades
Reverse Proxy & TLS
- Terminate TLS at the proxy and forward traffic to port 5678
- Set
WEBHOOK_URLto the public URL for inbound triggers
Upgrades
- Pin a tested tag, then use blue‑green or canary with a backup