Vultr DocsLatest Content

How to Deploy and Self-host n8n on Ubuntu 24.04

Updated on 16 September, 2025
Deploying n8n on Ubuntu 24.04 with Docker, secured by Nginx reverse proxy and Let's Encrypt SSL.
How to Deploy and Self-host n8n on Ubuntu 24.04 header image

n8n is an open-source workflow automation tool that enables you to connect various services and automate repetitive tasks through a visual node-based interface. The platform supports many integrations and provides both no-code and low-code capabilities for building complex workflows.

This article explains installing and configuring n8n on Ubuntu 24.04 with Docker, setting up Nginx as a reverse proxy, and securing the installation with TLS certificates.

Prerequisites

Before you begin:

Install Docker and Docker Compose

  1. Update the system packages.

    console
    $ sudo apt update
    
  2. Install prerequisite packages for Docker repository management.

    console
    $ sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
    
  3. Add Docker's official GPG key.

    console
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    
  4. Add the Docker repository to your system.

    console
    $ echo "deb [arch=$(dpkg --print-architecture) 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
    
  5. Update the package index.

    console
    $ sudo apt update
    
  6. Install Docker Engine, CLI, and Docker Compose plugin.

    console
    $ sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
    
  7. Add your user to the docker group to run Docker commands without sudo.

    console
    $ sudo usermod -aG docker $USER
    
  8. Apply the group changes to your current terminal session.

    console
    $ newgrp docker
    
  9. Verify the Docker installation.

    console
    $ docker --version
    

Create n8n Directory Structure

This section covers setting up a dedicated directory structure for n8n configuration files and data persistence.

  1. Create a directory for n8n.

    console
    $ mkdir ~/n8n
    
  2. Navigate to the n8n directory.

    console
    $ cd ~/n8n
    
  3. Create a data directory for n8n persistence.

    console
    $ mkdir n8n-data
    
  4. Create a directory for local file storage.

    console
    $ mkdir local-files
    
  5. The n8n container runs with UID 1000. Set proper ownership for the n8n data directory to match the container's user ID.

    console
    $ sudo chown -R 1000:1000 n8n-data local-files
    

Configure Docker Compose for n8n

In this section, create a Docker Compose configuration file for n8n.

  1. Create a new Docker Compose configuration file.

    console
    $ nano docker-compose.yml
    
  2. Add the following configuration to the file. Replace n8n.example.com with your actual domain.

    yaml
    services:
      n8n:
        image: n8nio/n8n:latest
        container_name: n8n
        restart: unless-stopped
        ports:
          - "5678:5678"
        environment:
          - N8N_HOST=n8n.example.com
          - N8N_PORT=5678
          - N8N_PROTOCOL=https
          - WEBHOOK_URL=https://n8n.example.com
          - N8N_EDITOR_BASE_URL=https://n8n.example.com
          - GENERIC_TIMEZONE=UTC
          - N8N_USER_FOLDER=/home/node/.n8n
        volumes:
          - ./n8n-data:/home/node/.n8n
          - ./local-files:/files
        networks:
          - n8n-network
    
    networks:
      n8n-network:
        driver: bridge
    

    Save and close the file.

    The above configuration creates an n8n container with persistent storage, HTTPS protocol settings, and support for webhooks.

Install and Configure Nginx

Nginx serves as a reverse proxy to handle HTTPS termination and forward requests to the n8n container. Install Nginx and create a server block configuration for your domain.

  1. Install Nginx.

    console
    $ sudo apt install nginx -y
    
  2. Create a new Nginx server block configuration. Replace n8n.example.com with your domain.

    console
    $ sudo nano /etc/nginx/sites-available/n8n.example.com
    
  3. Add the following configuration to the file. Replace n8n.example.com with your domain.

    ini
    server {
        listen 80;
        server_name n8n.example.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;
            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_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Port $server_port;
    
            # WebSocket support
            proxy_buffering off;
    
            # Timeout settings for long-running workflows
            proxy_read_timeout 300s;
            proxy_connect_timeout 75s;
        }
    }
    

    Save and close the file.

    The configuration includes WebSocket support and extended timeouts necessary for n8n's real-time updates and long-running workflows.

  4. Create a symbolic link to enable the site.

    console
    $ sudo ln -s /etc/nginx/sites-available/n8n.example.com /etc/nginx/sites-enabled/
    
  5. Test the Nginx configuration for syntax errors.

    console
    $ sudo nginx -t
    
  6. Reload Nginx to apply the configuration.

    console
    $ sudo systemctl reload nginx
    

Configure Firewall Rules

In this section, configure your firewall rules to allow necessary traffic.

  1. Allow HTTP traffic for initial setup and SSL certificate validation.

    console
    $ sudo ufw allow 80/tcp
    
  2. Allow HTTPS traffic for secure access.

    console
    $ sudo ufw allow 443/tcp
    

Install Certbot and Obtain TLS Certificate

Certbot automates TLS certificate generation and renewal using Let's Encrypt. Secure your n8n installation with HTTPS to protect data transmission and enable secure webhook endpoints.

  1. Install Certbot and the Nginx plugin.

    console
    $ sudo apt install certbot python3-certbot-nginx -y
    
  2. Obtain an TLS certificate for your domain. Replace n8n.example.com with your domain and admin@example.com with your email address.

    console
    $ sudo certbot --nginx -d n8n.example.com --email admin@example.com --agree-tos --non-interactive
    

    Certbot automatically modifies your Nginx configuration to include TLS settings and sets up automatic certificate renewal.

  3. Test automatic certificate renewal.

    console
    $ sudo certbot renew --dry-run
    

    A successful dry run confirms that automatic renewal is configured correctly.

Start n8n

In this section, deploy the n8n container using Docker Compose and verify the installation.

  1. Navigate to the n8n directory.

    console
    $ cd ~/n8n
    
  2. Start n8n in detached mode.

    console
    $ docker compose up -d
    
  3. Check the container status.

    console
    $ docker compose ps
    
  4. View the container logs to verify successful startup.

    console
    $ docker logs n8n
    

    Sample Output:

    ...
    n8n ready on https://n8n.example.com

Access and Configure n8n

Complete the initial setup by creating an admin account and configuring basic settings.

  1. Open a web browser and navigate to your n8n domain.

    https://n8n.example.com
  2. Create your admin account by providing your email, name, and password.

  3. Access the n8n workflow editor to start creating automations.

  4. You can browse the available workflows from the Templates section, or create your own workflow agent.

Manage n8n Container

Use these commands to manage your n8n installation.

View Logs

Monitor n8n logs in real-time.

console
$ docker logs -f n8n

Stop n8n

Stop the n8n container.

console
$ docker compose down

Restart n8n

Restart the n8n container.

console
$ docker compose restart

Update n8n

Update to the latest n8n version.

console
$ docker compose pull
$ docker compose up -d

Conclusion

You have successfully installed n8n on Ubuntu 24.04 with Docker, configured Nginx as a reverse proxy, and secured the installation with TLS certificates. Your n8n server is now ready to create workflow automations. The containerized deployment ensures easy maintenance, updates, and scalability as your automation needs grow. For more information, visit the n8n documentation.

Comments

No comments yet.