Unlocking Automation with n8n.io: A Comprehensive Guide to Installation on VPS Using Docker

Anaz S. AjiAnaz S. Aji
5 min read

Automation is a key factor in modern workflows, enabling businesses and individuals to streamline tasks, integrate services, and increase efficiency. n8n.io is a powerful, open-source workflow automation tool that empowers users to automate complex processes with ease. This article will delve into what n8n.io is, its key features, and provide a detailed guide on how to install it on a VPS using Docker.

What is n8n.io?

n8n.io is an open-source workflow automation tool that allows you to connect different applications and services to automate tasks and processes. It stands out for its flexibility and ease of use, providing a visual interface to design workflows without needing extensive coding knowledge. n8n.io supports a wide range of integrations, making it a versatile choice for various automation needs.

Key Features of n8n.io

  1. Visual Workflow Designer: n8n.io provides a user-friendly, drag-and-drop interface for creating and managing workflows, making it accessible to users with different technical backgrounds.

  2. Extensive Integrations: It supports over 200 integrations with popular services such as Google Sheets, Slack, GitHub, and more, enabling seamless automation across platforms.

  3. Self-Hosting: Being open-source, n8n.io can be self-hosted, giving you full control over your data and workflows.

  4. Scalability: n8n.io can handle complex workflows and large amounts of data, making it suitable for both small and enterprise-level applications.

  5. Custom Nodes: Users can create custom nodes to extend n8n.io’s functionality, allowing for highly tailored automation solutions.

  6. Secure: n8n.io prioritizes security with features like credential encryption and access control.

Why Use n8n.io?

  • Flexibility: n8n.io’s open-source nature allows for extensive customization and control over your automation processes.

  • Cost-Effective: Being free and open-source, n8n.io eliminates the need for expensive automation tools.

  • Community Support: A vibrant community offers support, plugins, and shared workflows, enhancing the overall user experience.

  • Ease of Use: The visual designer simplifies the creation of complex workflows, reducing the need for extensive programming knowledge.

Installing n8n.io on a VPS Using Docker

Installing n8n.io on a Virtual Private Server (VPS) using Docker ensures a streamlined, isolated, and easily manageable setup. Here’s a step-by-step guide to help you get started.

Prerequisites

  1. A VPS: You’ll need a VPS with a modern operating system (Ubuntu 20.04 or later is recommended).

  2. Docker and Docker Compose: Ensure Docker and Docker Compose are installed on your VPS. If not, follow these steps:

     sudo apt update
     sudo apt install apt-transport-https ca-certificates curl software-properties-common
     curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
     sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
     sudo apt update
     sudo apt install docker-ce
     sudo systemctl start docker
     sudo systemctl enable docker
     sudo apt install docker-compose
    

Step 1: Create a Directory for n8n.io

Create a directory to hold your n8n.io configuration and data:

mkdir ~/n8n-docker
cd ~/n8n-docker

Step 2: Create a Docker Compose File

Create a docker-compose.yml file in the directory with the following content:

version: '3.8'
services:
  n8n-postgres:
    image: postgres:15
    container_name: n8n-posgres
    environment:
      POSTGRES_USER: <your_username>              #Change with your DB Username
      POSTGRES_PASSWORD: <your_password>          #Change with your DB Password
      POSTGRES_DB: n8n-postgres-db
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    restart: always
    networks:
      - n8n-network
  n8n:
    image: n8nio/n8n:1.47.1
    container_name: n8n
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_DATABASE=n8n-postgres-db
      - DB_POSTGRESDB_HOST=n8n-posgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_USER=<your_username>        #Change with your DB Username
      - DB_POSTGRESDB_PASSWORD=<your_password>    #Change with your DB Password
      - TZ=Asia/Jakarta                           #Change with your timezone
      - GENERIC_TIMEZONE=Asia/Jakarta             #Change with your timezone
      - NODE_ENV=production
      - N8N_HOST=<your_ip_public>                 #Change with your IP Public
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - N8N_PUSH_BACKEND=websocket
      - N8N_PROXY_HOPS=1
      - N8N_EDITOR_BASE_URL=https://ajianaz.dev/  #Change with your domain
      - N8N_HIDE_WATERMARK=true
      - WEBHOOK_URL=https://ajianaz.dev/          #Change with your domain
    volumes:
      - ./n8n_data:/home/node/.n8n
    restart: unless-stopped
    depends_on:
      - n8n-postgres
    networks:
      - n8n-network
networks:
  n8n-network:
    driver: bridge

Replace <your_username>, <your_password>, <your_ip_public> and others value with your desired values.

Step 3: Start n8n.io with Docker Compose

Run the following command to start n8n.io using Docker Compose:

docker-compose up -d

This command will download the n8n.io Docker image and start the service in detached mode.

If you’re running n8n.io on a domain, it’s recommended to set up DNS and SSL for secure access. Use tools like Certbot and Nginx for SSL configuration.

Install Nginx

sudo apt install nginx

Configure Nginx for SSL

Use Certbot to obtain an SSL certificate:

sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d <your_domain>

Replace <your_domain> with your actual domain name.

Configure Nginx Proxy

Create an Nginx configuration file for n8n.io:

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

Add the following content:

server {
    listen 80;
    server_name <your_domain>;

    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;
    }

    listen [::]:443 ssl ipv6only=on;
    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/<your_domain>/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/<your_domain>/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}

Enable the configuration and restart Nginx:

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

Step 5: Access n8n.io

Navigate to https://<your_domain> or http://<your_ip>:5678 in your web browser. Log in using the username and password you specified in the Docker Compose file.

Conclusion

n8n.io is a versatile and powerful tool for automating workflows across various applications and services. By following this comprehensive guide, you can install n8n.io on your VPS using Docker, giving you full control over your automation processes. With its visual workflow designer, extensive integrations, and robust feature set, n8n.io can significantly enhance your productivity and efficiency. Start exploring n8n.io today and unlock the full potential of workflow automation.

0
Subscribe to my newsletter

Read articles from Anaz S. Aji directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Anaz S. Aji
Anaz S. Aji

I am a dedicated Mobile Developer with a strong passion for exploring the latest advancements in technology and the dynamic world of cryptocurrency. My curiosity and enthusiasm drive me to continuously seek out and experiment with innovative solutions, ensuring that I stay at the forefront of industry trends and developments.