Deploy the powerful workflow automation platform n8n to AWS EC2 using Docker Compose, Queue Mode, PostgreSQL 16, Redis BullMQ, and Nginx reverse proxy. Built for 99.9% uptime and zero-downtime rolling updates.
Incoming Traffic (Cloudflare / Web)
│
▼
Nginx Reverse Proxy
(Port 80 / 443)
/ \
UI & WebSocket / \ /webhook/*
▼ ▼
n8n-main n8n-webhook
(UI & Scheduler) (High Throughput Ingest)
\ /
▼ ▼
Redis (BullMQ Queue)
│
▼
n8n-worker Cluster
(Scalable 1, 2, 4+)
│
▼
PostgreSQL 16 DB
- 🔄 Queue Mode Execution: UI, Webhooks, and Workers are completely decoupled.
- ⚡ Dedicated Webhook Handler: Independent high-throughput worker for
/webhook/*endpoints. - 📈 Horizontal Worker Scaling: Add or remove background workers anytime with zero downtime.
- 🛡️ Zero-Downtime Deployment: Rolling container restarts with automated health check verification.
- 💾 Automated Backups: Daily compressed PostgreSQL dumps with 14-day auto-retention cleanup.
Copy .env.example to .env and fill in your values:
DOMAIN_NAME=n8n.yourdomain.com
N8N_ADMIN_EMAIL=admin@yourdomain.com
N8N_ADMIN_PASSWORD=your_secure_password
N8N_ENCRYPTION_KEY=your_encryption_key_here
POSTGRES_PASSWORD=your_postgres_password_here
REDIS_PASSWORD=your_redis_password_hereDeploy directly to your EC2 instance using your .pem key:
./remote-deploy.sh <EC2_PUBLIC_IP> ubuntu ./n8n-server-key.pemThis will automatically:
- Connect via SSH.
- Initialize Docker, Compose, and 3GB Swap space on the VPS (if not installed).
- Sync repository configuration.
- Launch n8n in high-scale Queue Mode.
# 1. Clone the repository
git clone https://github.com/developer-sujon/n8n.git n8n-server
cd n8n-server
# 2. Configure environment
cp .env.example .env
nano .env
# 3. Initialize server environment (Docker, Firewall, Swap)
./setup-server.sh
# 4. Deploy n8n cluster
./deploy.shScale background worker processes dynamically based on workload:
# Scale to 4 workers
./scale.sh 4
# Scale back to 2 workers
./scale.sh 2# Create manual compressed backup
./backup.sh
# Backups are saved to ./backups/n8n_backup_YYYYMMDD_HHMMSS.sql.gz- In Cloudflare or your DNS provider, create an A Record:
- Name:
n8n(or your chosen subdomain) - IPv4 Address:
<YOUR_EC2_PUBLIC_IP> - Proxy status: Proxied (Orange Cloud) for instant SSL, or DNS only.
- Name:
- Visit
https://your-domain.comin your browser. - Log in with your admin credentials configured in
.env.
n8n is a fair-code licensed workflow automation platform — a self-hosted, scalable alternative to Zapier and Make.
- 🔌 400+ built-in node integrations
- 🎨 Visual canvas workflow builder
- 🤖 Advanced AI Agent workflows with LangChain
- 🔐 Self-hosted on your own AWS infrastructure — complete data ownership