Deploy n8n like a boss on Azure! This repo helps you set up n8n faster than you can say "automation" (okay, maybe not that fast, but pretty close).
- π³ Docker-powered goodness
- π Auto-HTTPS (because security is cool)
- πΎ PostgreSQL that actually remembers stuff
- π€ n8n ready to automate your life
- π§ Scripts that do the heavy lifting
Because manually setting up n8n on Azure is about as fun as debugging production at 3 AM. This template does all the boring stuff for you, so you can focus on building awesome workflows instead.
About $15/month - cheaper than your coffee addiction! β
Perfect for: People who love automation but hate complicated setups. Not perfect for: People who enjoy spending weekends configuring servers (you know who you are).
Ready to make your life easier? Check out the docs below! π
This repository contains templates and scripts to deploy n8n workflow automation platform on Azure Virtual Machine. This deployment uses Docker and Docker Compose for running n8n and PostgreSQL, with Caddy as a reverse proxy for automatic HTTPS.
The deployment consists of:
- Azure B1ms VM (1 vCPU, 2GB RAM)
- Ubuntu 22.04 LTS
- Docker & Docker Compose
- n8n Community Edition
- PostgreSQL database
- Caddy web server (for HTTPS)
- Automatic backups
- Basic monitoring
- Azure CLI installed
curl -sL https://aka.ms/InstallAzureCLI | bash
- Azure subscription
az login
- A domain name pointed to Azure VM's IP (will be obtained during deployment)
.
βββ n8n-vm-template.json # Azure ARM template for VM
βββ deploy.sh # Deployment script
βββ setup.sh # VM setup script
βββ docker-compose.yml # Docker composition for n8n
βββ backup.sh # Backup script
βββ README.md # This file
git clone https://github.com/jawand/n8n-azure-deploy
cd n8n-azure-deploy
Edit deploy.sh
and set your preferred values:
RESOURCE_GROUP="n8n-rg"
LOCATION="eastus"
VM_NAME="n8n-vm"
ADMIN_USERNAME="n8nadmin"
chmod +x deploy.sh
./deploy.sh
The script will:
- Create a resource group
- Generate SSH keys if needed
- Deploy the VM using ARM template
- Output connection information
- The VM public IP is Dynamic, so you need to use Azure DNS record to point to your domain.
Point your domain to the VM's DNS Name (shown in deployment output). We cannot use IP address because it is dynamic and will change when the VM is restarted. Additionally, we are using Caddy as a reverse proxy to automatically handle HTTPS.
Make sure to create CNAME
record for n8n.example.com
to point to the VM's DNS Name (found in deployment output) on your Domain Registrar.
We need the DNS configured before we setup n8n server because Caddy will use the DNS to get the SSL certificate from Let's Encrypt and if its not ready then SSL will not generate & will throw an error, because Caddy will not be able to get the SSL certificate since it will not find the DNS record. I will recommend to wait for 10-15 minutes after you have pointed your subdomain to Azure VM DNS Name, before we setup n8n server.
- SSH into the VM:
ssh -i ~/.ssh/id_rsa_n8n n8nadmin@<VM_IP>
- Open new Terminal and Copy setup files:
# From your local machine
scp -i ~/.ssh/id_rsa_n8n setup.sh docker-compose.yml backup.sh n8nadmin@<VM_IP>:~/
- It will copy all the files to the VM.
- Run setup:
chmod +x setup.sh
./setup.sh
It will ask for domain name, Please provide your domain name. I prefer to use subdomain like n8n.yourdomain.com
.
cd n8n
docker-compose up -d
- we are using volume to persist n8n data to make sure data is not lost when containers are restarted.
Once deployment is complete, you can access n8n at:
https://n8n.your-domain.com
Set your own credentials at the first login.
Contains service definitions for:
- n8n
- PostgreSQL
Key configurations:
services:
n8n:
image: docker.io/n8nio/n8n:latest
ports:
- "5678:5678"
environment:
- N8N_HOST=${N8N_HOST}
- WEBHOOK_URL=https://${N8N_HOST}
- NODE_ENV=production
- N8N_PROTOCOL=https
- N8N_SSL_CERT=/etc/caddy/certificates/${N8N_HOST}.crt
- N8N_PORT=5678
- GENERIC_TIMEZONE=UTC
volumes:
- n8n_data:/home/node/.n8n
depends_on:
- postgres
postgres:
image: postgres:14-alpine
environment:
- POSTGRES_USER=n8n
- POSTGRES_PASSWORD=password
- POSTGRES_DB=n8n
volumes:
- postgres_data:/var/lib/postgresql/data
The backup.sh
script performs:
- PostgreSQL database dumps
- n8n data volume backup
- Optional upload to Azure Storage
To enable automatic backups:
(crontab -l 2>/dev/null; echo "0 0 * * * /home/n8nadmin/backup.sh") | crontab -
Update n8n and PostgreSQL:
docker-compose pull
docker-compose up -d
- Check container status:
docker-compose ps
- View logs:
docker-compose logs -f
- Monitor system resources:
htop
Manual backup:
./backup.sh
-
Firewall rules are configured to allow only:
- SSH (22) Please make sure to disable SSH port 22 in Azure portal.
- HTTPS (443)
-
SSH access:
- SSH Key-based authentication only and is stored at
~/.ssh/id_rsa_n8n
on your local machine. - Password authentication disabled
- SSH Key-based authentication only and is stored at
-
n8n security:
- HTTPS enforced
- Regular security updates
-
Cannot connect to n8n:
- Check VM status in Azure portal
- Verify domain DNS settings
- Check docker containers:
docker-compose ps
-
Database connection issues:
- Check PostgreSQL logs:
docker-compose logs postgres
- Verify environment variables in docker-compose.yml
- Check PostgreSQL logs:
-
SSL/HTTPS issues:
- Check Caddy logs:
sudo journalctl -u caddy
- Verify domain points to correct IP
- Check Caddy logs:
Monthly cost breakdown:
- VM (B1ms): ~$13.14
- Storage (OS Disk): ~$2.40
- Total: ~$15.54/month
For issues:
- Check the n8n documentation
- Open an issue in this repository
- Check n8n community forums
This deployment template is MIT licensed. n8n is licensed under its own terms.