1. Start With a Clean Server
- Deploy a Docker Droplet from the DigitalOcean Marketplace.
- Log in as root via SSH.
2. Update Your System (Recommended)
apt update && apt upgrade -y
3. Create a Folder for n8n
mkdir -p /root/n8n
cd /root/n8n
4. Create Your docker-compose.yml File
Create and edit the file:
nano /root/n8n/docker-compose.yml
Paste the following content (replace your.domain.com with your actual subdomain):
services:
n8n:
image: n8nio/n8n
container_name: n8n
restart: unless-stopped
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin # Change this!
- N8N_BASIC_AUTH_PASSWORD=strongpass # Change this!
- N8N_HOST=your.domain.com
- N8N_PORT=5678
- WEBHOOK_URL=https://your.domain.com/
- N8N_PROTOCOL=https
- N8N_SECURE_COOKIE=true
volumes:
- ./data:/home/node/.n8n
networks:
- n8n_network
caddy:
image: caddy:alpine
container_name: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
networks:
- n8n_network
networks:
n8n_network:
volumes:
caddy_data:
caddy_config:
5. Create Your Caddyfile
nano /root/n8n/Caddyfile
Paste this (replace your.domain.com):
your.domain.com {
reverse_proxy n8n:5678
}
6. Set Permissions (for volume folder)
mkdir -p /root/n8n/data
chown -R 1000:1000 /root/n8n/data
7. Point Your Domain DNS to the Server IP
- In your domain registrar, create an A record for your.domain.com → your server’s public IP.
8. Start Everything Up
From /root/n8n:
docker compose up -d
9. Open Firewall (if using UFW)
sudo ufw allow 80
sudo ufw allow 443
sudo ufw reload
10. Access n8n!
- Visit https://your.domain.com in your browser.
- Log in with the username and password you set in the Compose file.
11. Updating n8n in the Future
docker compose pull
docker compose up -d
12. Restarting After Changes (e.g., new domain in Caddyfile)
docker compose restart caddy
(or docker compose restart to restart all)
Summary Table
Step | Command / File | Purpose |
---|---|---|
Create dir | mkdir -p /root/n8n | App folder |
Compose file | nano /root/n8n/docker-compose.yml | Stack config |
Caddyfile | nano /root/n8n/Caddyfile | HTTPS reverse proxy |
Start stack | docker compose up -d | Run in background |
Firewall | ufw allow 80; ufw allow 443 | Allow web access |
Update DNS | Domain → your server IP | Domain resolves |
Pro Tips
- You can change credentials and domain anytime—just update the files and restart.
- Data is stored in /root/n8n/data—back this up regularly!
- Caddy will auto-renew your free SSL certificate.
- No manual SSL setup needed!