In this guide, we’ll deploy a complete n8n automation system on Ubuntu, including PostgreSQL, Redis, NGINX, SSL (Certbot), and monitoring tools such as Netdata and Uptime Kuma, plus a daily automatic backup system.
The entire stack is managed using Docker Compose, making it easy to scale, maintain, and ensure a stable environment for n8n.
How the System Works:
-
Users access the system through an HTTPS domain, protected by NGINX and SSL certificates from Certbot.
-
NGINX acts as a reverse proxy, routing requests to n8n, Netdata, and Uptime Kuma.
-
When an event or trigger occurs, n8n executes the corresponding workflow.
-
n8n pushes tasks into the Redis queue for asynchronous processing.
-
n8n workers fetch tasks from Redis and execute them.
-
Execution results and logs are stored in the PostgreSQL database.
-
Configuration data and internal files are saved in the n8n_data volume.
-
Netdata monitors system and container performance in real time.
-
Uptime Kuma tracks the uptime of services and stores logs in kuma_data.
-
The backup system automatically saves PostgreSQL data and Docker volumes daily for data recovery when needed.
mục lục
- Step 1: Update and Install Basic Components:
- Step 2: Install Netdata for System Monitoring
- Step 3: Create and Configure Docker Compose for n8n
- Step 4: Launch the Docker Stack
- Step 5: Configure NGINX Reverse Proxy and SSL
- Step 6: Enable and Test the Site
- Step 7: Obtain SSL Certificate with Certbot
- Step 8: Set Up Auto Renewal
- Step 9: Access Your Interfaces
- Step 10: Set Up Automatic Backup System
- Conclusion
Step 1: Update and Install Basic Components:
sudo apt update && sudo apt install -y docker.io docker-compose nginx certbot python3-certbot-nginx git curl
sudo systemctl enable –now docker
sudo systemctl enable –now nginx


Step 2: Install Netdata for System Monitoring
bash <(curl -Ss https://get.netdata.cloud/kickstart.sh)

Step 3: Create and Configure Docker Compose for n8n
nano docker-compose.yml
version: “3.9”
services:
postgres:
image: postgres:15
container_name: postgres
restart: unless-stopped
environment:
POSTGRES_USER: n8n
POSTGRES_PASSWORD: datacloudPass
POSTGRES_DB: n8n
ports:
– “5432:5432”
volumes:
– pg_data:/var/lib/postgresql/data
networks:
– datacloud
redis:
image: redis:7
container_name: redis
restart: unless-stopped
networks:
– datacloud
n8n:
image: n8nio/n8n:1.113.3
container_name: n8n
restart: unless-stopped
environment:
– N8N_HOST=n8n.datacloud.vn
– WEBHOOK_URL=https://n8n.datacloud.vn/
– DB_TYPE=postgresdb
– DB_POSTGRESDB_HOST=postgres
– DB_POSTGRESDB_PORT=5432
– DB_POSTGRESDB_DATABASE=n8n
– DB_POSTGRESDB_USER=n8n
– DB_POSTGRESDB_PASSWORD=datacloudPass
– EXECUTIONS_MODE=queue
– QUEUE_BULL_REDIS_HOST=redis
– QUEUE_BULL_REDIS_PORT=6379
ports:
– “5678:5678”
volumes:
– n8n_data:/home/node/.n8n
depends_on:
– postgres
– redis
networks:
– datacloud
uptime-kuma:
image: louislam/uptime-kuma:latest
container_name: uptime-kuma
restart: unless-stopped
ports:
– “3001:3001”
volumes:
– ./kuma-data:/app/data
networks:
– datacloud
volumes:
pg_data:
n8n_data:
networks:
datacloud:
driver: bridge

Step 4: Launch the Docker Stack
docker compose up -d
docker ps

Step 5: Configure NGINX Reverse Proxy and SSL
server {
server_name n8n.datacloud.vn;
# n8n
location / {
proxy_pass http://localhost: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;
}
# Netdata /netdata/
location /netdata/ {
proxy_pass http://localhost:19999/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/n8n.datacloud.vn/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/n8n.datacloud.vn/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = n8n.datacloud.vn) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name n8n.datacloud.vn;
listen 80;
return 404; # managed by Certbot
}

Step 6: Enable and Test the Site
ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx

Step 7: Obtain SSL Certificate with Certbot
certbot –nginx -d n8n.datacloud.vn

Step 8: Set Up Auto Renewal
crontab -e
0 2 * * * certbot renew –quiet –post-hook “systemctl restart nginx”
Step 9: Access Your Interfaces
https://n8n.datacloud.vn → n8n Dashboard

http://n8n.datacloud.vn:3001 -> Uptime Kuma Dashboard


https://n8n.datacloud.vn/netdata → Netdata Monitoring
sudo cat /var/lib/netdata/netdata_random_session_id


Step 10: Set Up Automatic Backup System
Step 10.1: Create Backup Directory
mkdir -p /root/backups/logs
Step 10.2: Download Backup Script
wget https://script.datacloudvn.com/n8n/backup_n8n.sh
chmod +x /root/backup_n8n.sh
Step 10.3: Test Backup
bash /root/backup_n8n.sh
ls -lh /root/backups
Step 10.4: Schedule Daily Backup at 01:00 AM
crontab -e
0 1 * * * /root/backup_n8n.sh
Step 10.5: Verify Cron Service
systemctl status cron
sudo grep CRON /var/log/syslog

Conclusion
We have successfully deployed a complete n8n system with all the essential components database, queue, monitoring, SSL security, and automated daily backups.
This architecture is scalable, recoverable, and easy to monitor, making it ideal for real-world workflow automation environments.



Tiếng Việt