# Production deployment of n8n workflow automation platform

&#x20;**Overview**

This document provides a complete, production-ready installation and configuration guide for deploying **n8n** on **Ubuntu 22.04**, including:

* Docker-based installation
* Reverse proxy configuration using NGINX
* HTTPS enablement using Let’s Encrypt

The guide ensures a secure, stable, and scalable deployment suitable for enterprise use.

***

**System Requirements**

**Virtual Machine Specifications**

| Component        | Minimum Requirement | Recommended         |
| ---------------- | ------------------- | ------------------- |
| Operating System | Ubuntu 22.04 LTS    | –                   |
| CPU              | 2 vCPU              | 2–4 vCPU            |
| RAM              | 4 GB                | 4–8 GB              |
| Storage          | 20 GB               | 40–50 GB SSD        |
| Network          | Public IP Address   | Static IP Preferred |

**Required Ports**

| Purpose       | Port |
| ------------- | ---- |
| SSH           | 22   |
| n8n Web UI    | 5678 |
| HTTP (NGINX)  | 80   |
| HTTPS (NGINX) | 443  |

**Prerequisites**

Ensure the following before starting:

&#x20;A working Ubuntu 22.04 VM\
&#x20;Public IP reachable over the internet\
&#x20;Domain name pointing to the server

To verify domain DNS resolution:

```bash
nslookup yourdomain.com
```

***

**Step1: Install Docker & Docker Compose**

**1.1 Update System Packages**

```bash
sudo apt update && sudo apt upgrade -y
```

**1.2 Install Docker Engine**

```bash
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
```

**1.3 Install Docker Compose**

```bash
sudo apt install -y docker-compose
```

**1.4 Verification**

Check Docker service:

```bash
sudo systemctl status docker
```

Check versions:

```bash
docker --version
docker-compose --version
```

***

**Step2: Deploy n8n using Docker Compose**

**2.1 Create Directory**

```bash
mkdir ~/n8n-compose
cd ~/n8n-compose
```

**2.2 Create Docker Compose File**

```bash
sudo nano docker-compose.yml
```

**2.3 Add the Following Configuration**

```yaml
version: "3.3"

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "5678:5678"

    environment:
      - TZ=Asia/Kolkata
      - GENERIC_TIMEZONE=Asia/Kolkata

      # Basic Authentication
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=hello@123

      # Database
      - DB_TYPE=sqlite

      # Domain 
      - N8N_HOST=your-domain
      - N8N_PORT=5678
      - N8N_PROTOCOL=http

    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:
```

**save the file in nano.**

* Press **CTRL + O** → then press **Enter** to save
* Press **CTRL + X** to exit nano

**2.4 Start n8n Service**

```bash
docker compose up -d
```

**2.5 Validate Service**

```bash
docker ps
```

***

**Step3: Access n8n Web Interface**

If domain is not configured:

```
http://<server-ip>:5678
```

If Basic Authentication is enabled:

* Username: admin
* Password: hello\@123

After login, set:

* Email
* First Name
* Last Name
* New admin password

This will create the **primary Owner Account**.

***

**Step4: Configure NGINX Reverse Proxy**

**4.1 Install NGINX**

```bash
sudo apt install nginx -y
```

**4.2 Create Reverse Proxy Configuration**

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

Paste:

```nginx
server {
    listen 80;
    server_name yourdomain.com;   #your_domain_name

    location / {
        proxy_pass http://127.0.0.1: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;
    }
}
```

**save the file in nano.**

* Press **CTRL + O** → then press **Enter** to save
* Press **CTRL + X** to exit nano

**4.3 Enable Configuration**

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

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FAkV3Ch9bjouH0O1eJ8Rf%2Fimage.png?alt=media&#x26;token=05cdcab0-aac9-43f3-8b12-3cc33f4ed7ec" alt=""><figcaption></figcaption></figure>

***

**Step5: Enable HTTPS using Let’s Encrypt**&#x20;

**5.1 Install Certbot**

```bash
sudo apt install certbot python3-certbot-nginx -y
```

**5.2 Generate SSL Certificate**

```bash
sudo certbot --nginx -d yourdomain.com
```

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FsLXMPYu03UUAnDGkSXMy%2Fimage.png?alt=media&#x26;token=edde13d0-411c-4bb4-9fcb-117889270ecc" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FiwUH9FXPtwaqmX25PYSX%2Fimage.png?alt=media&#x26;token=b2aff73a-3d87-48bd-a6aa-bb861254b055" alt=""><figcaption></figcaption></figure>

Follow prompts:

* Enter email
* Accept Terms of Service: Yes
* Choose whether to share email
* Certbot applies SSL automatically

**5.3 Validate HTTPS**

Open:

```
https://yourdomain.com
```

Expected:

SSL padlock\
Secure connection\
n8n dashboard loads without port

**Step6: Deployment Completed Successfully**

> **n8n has been successfully installed on Ubuntu 22.04 with Docker, configured with NGINX Reverse Proxy, and secured with HTTPS using Let’s Encrypt.**

<figure><img src="https://1876135298-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEC5NwtFshv6EATOemuUn%2Fuploads%2FZokUqWLJmTDkuRfB6fsA%2Fimage.png?alt=media&#x26;token=9e3cd2e0-0706-48ec-a76f-f4bbbb778cb1" alt=""><figcaption></figcaption></figure>
