6/7/2025 β€’ Aegis

How to Install n8n on Ubuntu VPS (with Domain & SSL)

n8n ubuntu vps ssl automation self-hosting tutorial

πŸ’‘ Need help setting this up? Click here for a done-for-you service.

πŸš€ Introduction

Want to self-host n8n, the powerful open-source automation tool?
In this guide, you’ll learn how to install n8n on an Ubuntu VPS, configure a custom domain, secure it with SSL, and run it as a background system service using Nginx as a reverse proxy.

This tutorial is perfect for freelancers, devs, and small teams who want full control over their automation workflows.


βœ… Prerequisites

Before you begin, make sure you have:

  • An Ubuntu VPS (20.04 LTS or newer)
  • A registered domain pointing to your VPS IP
  • SSH access with sudo privileges
  • Basic knowledge of the Linux terminal

πŸ”§ Step 1: Update Your System

sudo apt update && sudo apt upgrade -y

πŸ”§ Step 2: Install Node.js (v18 LTS)

n8n requires Node.js. Install it via NodeSource:

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs

Verify it:

node -v
npm -v

πŸ”§ Step 3: Install n8n Globally

sudo npm install n8n -g

πŸ”§ Step 4: Run n8n as a Systemd Service

Create a service file:

sudo nano /etc/systemd/system/n8n.service

Paste and update the following:

[Unit]
Description=n8n workflow automation
After=network.target

[Service]
Type=simple
User=YOUR_USERNAME
Environment=N8N_HOST=your-domain.com
Environment=N8N_PORT=5678
Environment=N8N_PROTOCOL=https
Environment=NODE_ENV=production
ExecStart=/usr/bin/n8n start
Restart=on-failure

[Install]
WantedBy=multi-user.target

Then enable it:

sudo systemctl enable n8n
sudo systemctl start n8n

🌐 Step 5: Set Up Nginx Reverse Proxy

Install Nginx:

sudo apt install nginx -y

Create a config file:

sudo nano /etc/nginx/sites-available/n8n

Paste this (replace domain):

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_cache_bypass $http_upgrade;
    }
}

Enable and restart:

sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

πŸ”’ Step 6: Secure with SSL (Let’s Encrypt)

Install Certbot:

sudo apt install certbot python3-certbot-nginx -y

Generate your certificate:

sudo certbot --nginx -d your-domain.com

Done! HTTPS is now active πŸŽ‰


🌐 Step 7: Access Your n8n Dashboard

Visit: https://your-domain.com You’ll be prompted to set up your admin account. From here, you can start building automated workflows.


🎯 Final Checklist

βœ… n8n running as a background service

βœ… Accessible via your own domain

βœ… Secured with SSL (HTTPS)

βœ… Ready for workflow building


πŸ” Next Steps

  • πŸ” Configure .env for sensitive credentials
  • πŸ’Ύ Set up regular backups
  • πŸ›‘οΈ Harden your VPS with fail2ban and ufw
  • πŸ“‹ Monitor logs with journalctl -u n8n

πŸ‘‹ Need Help Self-Hosting n8n?

I offer a complete n8n installation service, including:

  • βœ… VPS setup (Ubuntu/Windows/local)
  • βœ… Domain + SSL + reverse proxy
  • βœ… Optional Postgres & backup configuration

πŸ‘‰ Get started now β€” typically completed in just a few hours.