Multi-Instance n8n Deployment Guide on Ubuntu
A step-by-step procedure for secure installation and independent management of multiple n8n instances on a single host.
1️⃣ User Account Creation
Establish a dedicated, non-root system user (user) for running the n8n processes for enhanced security. This is mandatory for service isolation.
sudo usermod -aG sudo user # Optional: Grants user sudo privileges
Switch to the new user before proceeding with the installation:
2️⃣ Node.js (LTS) Installation
Install Node.js (Long-Term Support version recommended) and required build tools.
sudo apt install -y nodejs build-essential
node -v
npm -v
3️⃣ Global n8n Installation
Install the n8n application globally using npm. Verify the executable path for systemd configuration.
which n8n
Expected executable path: /usr/local/bin/n8n
4️⃣ Instance Data Directory Configuration
Create separate data directories for each n8n instance to ensure isolation of databases, credentials, and settings.
Configuration Matrix
| Instance Name | Data Folder | Internal Port | Public Domain |
|---|---|---|---|
| n8n | /home/user/.n8n | 5678 | n8n.example.com |
| n8n1 | /home/user/.n8n1 | 5680 | n8n1.example.com |
| n8n2 | /home/user/.n8n2 | 5682 | n8n2.example.com |
Command to create data directories:
mkdir -p /home/user/.n8n1
mkdir -p /home/user/.n8n2
5️⃣ Systemd Service Definition
Define independent service files in /etc/systemd/system/ for reliable startup, restart, and user management for each instance. Use sudo nano /etc/systemd/system/n8n.service (and similarly for n8n1/n8n2) to create these files.
Service Configuration: n8n.service
[Unit] Description=n8n workflow automation After=network.target [Service] ExecStart=/usr/local/bin/n8n Restart=always User=user Environment=PATH=/usr/bin:/usr/local/bin Environment=NODE_ENV=production Environment=N8N_PORT=5678 Environment=N8N_HOST=n8n.example.com Environment=N8N_PROTOCOL=https Environment=N8N_WEBHOOK_URL=https://n8n.example.com/ Environment=N8N_EDITOR_BASE_URL=https://n8n.example.com Environment=N8N_USER_FOLDER=/home/user/.n8n WorkingDirectory=/home/user [Install] WantedBy=multi-user.target
Service Configuration: n8n1.service
[Unit] Description=n8n (second instance) After=network.target [Service] ExecStart=/usr/local/bin/n8n Restart=always User=user Environment=PATH=/usr/bin:/usr/local/bin Environment=NODE_ENV=production Environment=N8N_PORT=5680 Environment=N8N_HOST=n8n1.example.com Environment=N8N_PROTOCOL=https Environment=N8N_WEBHOOK_URL=https://n8n1.example.com/ Environment=N8N_EDITOR_BASE_URL=https://n8n1.example.com Environment=N8N_USER_FOLDER=/home/user/.n8n1 WorkingDirectory=/home/user [Install] WantedBy=multi-user.target
Service Configuration: n8n2.service
[Unit] Description=n8n (third instance) After=network.target [Service] ExecStart=/usr/local/bin/n8n Restart=always User=user Environment=PATH=/usr/bin:/usr/local/bin Environment=NODE_ENV=production Environment=N8N_PORT=5682 Environment=N8N_HOST=n8n2.example.com Environment=N8N_PROTOCOL=https Environment=N8N_WEBHOOK_URL=https://n8n2.example.com/ Environment=N8N_EDITOR_BASE_URL=https://n8n2.example.com Environment=N8N_USER_FOLDER=/home/user/.n8n2 WorkingDirectory=/home/user [Install] WantedBy=multi-user.target
6️⃣ Enable and Start Services
Apply the new systemd configurations and activate the services.
sudo systemctl enable n8n
sudo systemctl enable n8n1
sudo systemctl enable n8n2
sudo systemctl start n8n
sudo systemctl start n8n1
sudo systemctl start n8n2
Monitor logs for initial startup confirmation (use Ctrl+C to exit):
7️⃣ Nginx Reverse Proxy and SSL Setup
Configure Nginx to proxy external traffic to the correct internal ports (5678, 5680, 5682). Create this configuration file for **each domain**.
Example Nginx Server Block: n8n1.example.com.conf
server { server_name n8n1.example.com; location / { proxy_pass http://127.0.0.1:5680; 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; } }
Activate the configuration and reload Nginx:
sudo nginx -t
sudo systemctl reload nginx
Acquire SSL Certificate using Certbot:
8️⃣ Prerequisite: DNS Configuration
Confirmation of required **A records** is essential prior to Nginx configuration and SSL issuance. Ensure all subdomains point to the server’s public IP address.
Required DNS Records:
| Type | Name | Value (Server IP) |
|---|---|---|
| A | n8n | your-server-ip |
| A | n8n1 | your-server-ip |
| A | n8n2 | your-server-ip |
9️⃣ Individual Instance Reset Procedure
To perform a factory reset, deleting all persistent data (workflows, credentials, users) and forcing the initial “Create Account” screen to reappear:
Resetting Instance: n8n1
sudo rm -rf /home/user/.n8n1 # WARNING: This command permanently deletes all instance data.
sudo mkdir -p /home/user/.n8n1
sudo chown -R user:user /home/user/.n8n1
sudo systemctl start n8n1
Access after reset: https://n8n1.example.com
10️⃣ Command Management Reference
Quick reference for common service management commands, using n8n1 as the service example.
| Action | Command |
|---|---|
| Restart instance | sudo systemctl restart n8n1 |
| Stop instance | sudo systemctl stop n8n1 |
| View logs (real-time) | journalctl -u n8n1 -f |
| Delete all instance data | sudo rm -rf /home/user/.n8n1/* |
| Check Nginx config syntax | sudo nginx -t |
| Reload Nginx | sudo systemctl reload nginx |
| Enable automated SSL renewal | sudo systemctl enable certbot.timer |
Deployment Summary
Three fully isolated and managed n8n instances are configured:
| Instance | Data Folder | Internal Port | User | Domain |
|---|---|---|---|---|
| n8n | /home/user/.n8n | 5678 | user | n8n.example.com |
| n8n1 | /home/user/.n8n1 | 5680 | user | n8n1.example.com |
| n8n2 | /home/user/.n8n2 | 5682 | user | n8n2.example.com |
Each instance is running under its own systemd service, isolated by data directories and port, and accessible via HTTPS.
Güvercintepe su kaçak tespiti Profesyonel Raporlama: Sorunun kaynağını detaylı bir şekilde raporladılar. Çok profesyoneller. https://share.google/PU5VPospAdoIsYzq3
buy link buyhacklink.com site buyhacklink.com https://www.kadikoysukacagi.ipektesisat.com/
Hi, how have you been lately?
best jordan tour packages Natalie B. The Turkish night was full of energy! The costumes and dances were fantastic. https://seoflox.io/q/lntig-rank-website-on-first-page/