N8N Automation
⚙️ Self‑Hosting n8n on Oracle Cloud (Free Tier)
Section titled “⚙️ Self‑Hosting n8n on Oracle Cloud (Free Tier)”Automating repetitive tasks—social posting, data syncing, email processing—quickly becomes overwhelming.
n8n provides a powerful visual workflow engine, and hosting it yourself gives you full control.
This guide walks through deploying n8n on Ubuntu 24.04 using Oracle Cloud’s Free Tier, which offers a permanent, cost‑free VM.
🧩 Overview
Section titled “🧩 Overview”| Category | Details |
|---|---|
| Platform | n8n (Self‑Hosted) |
| Cloud Provider | Oracle Cloud Free Tier |
| Operating System | Ubuntu 24.04 LTS |
| Runtime | Node.js v22 (via NVM) |
| Process Manager | PM2 |
| Reverse Proxy | NGINX |
| SSL | Certbot + Let’s Encrypt |
1️⃣ Preparing the Server
Section titled “1️⃣ Preparing the Server”Creating the VM
Section titled “Creating the VM”| Step | Description |
|---|---|
| Sign Up | Create an account at oracle.com/cloud/free |
| Deploy Instance | Select Ubuntu 24.04 |
| Credentials | Save public IP and SSH private key |
Connect via SSH
Section titled “Connect via SSH”ssh -i ~/path/to/key.key ubuntu@<your-ip>
chmod 400 ~/path/to/key.key
Update the system
Section titled “Update the system”sudo apt update && sudo apt upgrade -y && sudo apt install -y \
build-essential curl wget git ufw ca-certificates gnupg \
lsb-release software-properties-common
2️⃣ Installing Node.js with NVM
Section titled “2️⃣ Installing Node.js with NVM”| Component | Purpose |
|---|---|
| NVM | Manages Node.js versions |
| Node.js v22 | Required runtime for n8n |
Install NVM
Section titled “Install NVM”curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm"
source "$NVM_DIR/nvm.sh"
Install Node.js v22
Section titled “Install Node.js v22”nvm install 22
nvm use 22
nvm alias default 22
node -v
3️⃣ Running n8n with PM2
Section titled “3️⃣ Running n8n with PM2”| Tool | Role |
|---|---|
| PM2 | Keeps n8n running and restarts it automatically |
| Startup Script | Loads environment variables and launches n8n |
Install PM2
Section titled “Install PM2”npm install -g pm2
pm2 -v
Create startup script
Section titled “Create startup script”nano ~/start-n8n.sh
Script content:
#!/bin/sh
set -a
. ~/.n8n/.env
set +a
npx n8n
Make executable:
chmod +x ~/start-n8n.sh
Start with PM2
Section titled “Start with PM2”pm2 start ~/start-n8n.sh --name n8n
pm2 startup
pm2 save
4️⃣ Reverse Proxy with NGINX
Section titled “4️⃣ Reverse Proxy with NGINX”| Component | Purpose |
|---|---|
| NGINX | Handles HTTP traffic and proxies to n8n |
| Port 80 | Public access |
Install NGINX
Section titled “Install NGINX”sudo apt update && sudo apt install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx
Configure NGINX for n8n
Section titled “Configure NGINX for n8n”sudo nano /etc/nginx/sites-available/n8n
Add:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:5678;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
proxy_buffering off;
proxy_cache off;
chunked_transfer_encoding off;
}
}
Enable the site:
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
5️⃣ Securing with SSL (Certbot)
Section titled “5️⃣ Securing with SSL (Certbot)”| Component | Purpose |
|---|---|
| Certbot | Generates and manages SSL certificates |
| Let’s Encrypt | Provides free HTTPS certificates |
Install Certbot
Section titled “Install Certbot”sudo apt install -y certbot python3-certbot-nginx
Generate certificate
Section titled “Generate certificate”sudo certbot --nginx -d your-domain.com
Enable auto‑renewal:
sudo systemctl enable certbot.timer
6️⃣ Hardening the Server
Section titled “6️⃣ Hardening the Server”Firewall (UFW)
Section titled “Firewall (UFW)”sudo ufw allow 22
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable
Optional: iptables rules
Section titled “Optional: iptables rules”sudo nano /etc/iptables/rules.v4
Apply:
sudo iptables-restore < /etc/iptables/rules.v4
7️⃣ Environment Variables for n8n
Section titled “7️⃣ Environment Variables for n8n”Create:
nano ~/.n8n/.env
Example:
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=yourusername
N8N_BASIC_AUTH_PASSWORD=yourpassword
WEBHOOK_TUNNEL_URL=https://your-domain.com/
Secure it:
chmod 600 ~/.n8n/.env
8️⃣ Maintenance & Troubleshooting
Section titled “8️⃣ Maintenance & Troubleshooting”pm2 logs n8n
Common issues
Section titled “Common issues”| Issue | Fix |
|---|---|
| n8n not responding | |
| Domain not resolving | Check DNS A record |
| NGINX errors | |
| Firewall blocking | Verify UFW rules |
Backups
Section titled “Backups”| What to Save | Frequency | Location |
|---|---|---|
| n8n config | Weekly | Cloud storage |
| .env file | Monthly | Encrypted drive |
| PM2 list | Monthly | |
| Scripts | After changes | Git repo |
🎯 Final Notes
Section titled “🎯 Final Notes”This setup gives you a fully self‑hosted, secure, always‑free n8n instance running on Oracle Cloud.
You can now build workflows, integrate APIs, automate tasks, and scale as needed.