Self-Host n8n: Build Powerful AI Workflows in 15 Minutes
Stop paying Zapier $50/month. Run your own automation engine on a $5 VPS.
n8n is the open-source answer to Zapier and Make.com — except you own your data, your workflows, and your bill. With 400+ integrations, native AI nodes, and a visual drag-and-drop builder, it’s become the go-to automation platform for developers and DevOps teams who refuse vendor lock-in.
In this guide, you’ll self-host n8n with Docker, secure it behind HTTPS, and trigger your first workflow. No fluff, no enterprise sales calls — just a working instance in 15 minutes.
What You’ll Build
- n8n running in Docker with persistent storage
- HTTPS via Traefik or Nginx Proxy Manager
- Basic auth and webhook security
- A working automation: "Email → AI Summary → Slack"
Prerequisites
- VPS with 2 vCPU, 4GB RAM, 20GB SSD (Hetzner CX21, DigitalOcean $12, or equivalent)
- Docker + Docker Compose installed
- A domain or subdomain pointed at your VPS (e.g.,
n8n.yourdomain.com) - Reverse proxy handling HTTPS (Traefik, NPM, or Caddy)
Step 1: Create the Docker Compose File
Create a directory and compose file:
mkdir -p ~/n8n && cd ~/n8n
nano docker-compose.yml
Paste this configuration:
version: "3.8"
services:
n8n:
image: docker.n8n.io/n8nio/n8n:latest
restart: unless-stopped
ports:
- "5678:5678"
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=changeme-strong-password
- N8N_HOST=n8n.yourdomain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://n8n.yourdomain.com/
- GENERIC_TIMEZONE=UTC
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
Security note: Change changeme-strong-password to a real password. If you’re exposing n8n to the internet, basic auth is the minimum — consider adding OAuth2 or VPN access for production.
Step 2: Launch n8n
docker compose up -d
Verify it’s running:
docker compose logs -f
You should see Editor is now accessible via: https://n8n.yourdomain.com:5678/
Step 3: Configure Your Reverse Proxy
Option A: Traefik
Add labels to your n8n service:
labels:
- "traefik.enable=true"
- "traefik.http.routers.n8n.rule=Host(\`n8n.yourdomain.com\`)"
- "traefik.http.routers.n8n.tls.certresolver=letsencrypt"
- "traefik.http.services.n8n.loadbalancer.server.port=5678"
Option B: Nginx Proxy Manager
Add a proxy host in the NPM UI:
- Domain:
n8n.yourdomain.com - Forward Hostname:
n8n - Forward Port:
5678 - Block Common Exploits: ✅
Step 4: Verify HTTPS and Access
Visit https://n8n.yourdomain.com — you should see the n8n login screen. Sign in with the basic auth credentials from your compose file.
Step 5: Build Your First AI Workflow
Let’s create a workflow that reads emails, summarizes them with OpenAI, and posts to Slack:
- Trigger: Add an "Email (IMAP)" trigger node. Connect to your Gmail or any IMAP server.
- AI Node: Add an "OpenAI" node. Set it to summarize the email body into 2 sentences.
- Action: Add a "Slack" node. Post the summary to a channel.
- Connect & Activate: Link the nodes, save, and toggle "Active".
That’s it. Every new email now gets summarized and pushed to Slack automatically.
Production Hardening Checklist
- Enable SSO or OAuth2 instead of basic auth
- Run n8n behind a VPN or internal network if possible
- Enable workflow execution logging for audit trails
- Set up
docker system prunecron to prevent disk bloat - Back up
/home/node/.n8nvolume regularly (contains all workflows + credentials)
Next Steps
- AI Agents: n8n now has native AI agent nodes. Build a RAG pipeline with vector stores.
- Self-Hosted LLMs: Swap OpenAI for Ollama running locally — zero API costs.
- Monitoring: Add Uptime Kuma to alert if n8n goes down.
- Backups: Use Borgmatic to back up your n8n data volume daily.
Bottom line: n8n replaces $50-200/month automation bills with a $5 VPS and 15 minutes of setup. The workflows are yours, the data is yours, and the integrations keep growing.
Questions? Drop them in the comments or reach out on our contact page.