1. DNS Configuration
Do this step only if you have your own domain
Type Name Value TTL
A @ 168.231.126.186 Auto
2. Setup variables on the server
Personalize your values here
DOMAIN="your_domain.com"
EMAIL="your_email@gmail.com"
3. Install Docker, Nginx, Certbot
apt-get update
apt-get install -y docker.io nginx certbot python3-certbot-nginx
systemctl enable --now docker
If you use a firewall later, allow web ports:
ufw allow 80/tcp && ufw allow 443/tcp
4. Install and run n8n
docker volume create n8n_data
docker run -d \
--name n8n \
--restart unless-stopped \
-p 127.0.0.1:5678:5678 \
-e N8N_HOST="$DOMAIN" \
-e N8N_PORT=5678 \
-e N8N_PROTOCOL="http" \
-e WEBHOOK_URL="https://$DOMAIN/" \
-v n8n_data:/home/node/.n8n \
n8nio/n8n:1.72.1
Quick check:
docker ps
docker logs --tail=60 n8n
curl -sI http://127.0.0.1:5678 | head -n1
(Expect HTTP/1.1 200 OK or 301.)
5. Serve your domain with nginx
cat >/etc/nginx/sites-available/n8n.conf <<EOF
server {
listen 80;
server_name $DOMAIN www.$DOMAIN;
location / {
proxy_pass http://127.0.0.1:5678;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
# (optional but harmless) upgrade headers
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
}
# generous timeouts for long runs/webhooks
proxy_read_timeout 3600;
proxy_connect_timeout 3600;
proxy_send_timeout 3600;
}
EOF
rm -f /etc/nginx/sites-enabled/default
ln -sf /etc/nginx/sites-available/n8n.conf /etc/nginx/sites-enabled/n8n.conf
nginx -t && systemctl reload nginx
6. Setup HTTPS with Certbot
certbot --nginx -d "$DOMAIN" -d "www.$DOMAIN" --redirect -m "$EMAIL" --agree-tos -n