Installing and Configuring n8n on Ubuntu 24.04 Using Docker and Nginx
n8n is an open-source automation platform that lets you interconnect different services and automate recurring actions through an intuitive, node-based visual interface. The tool supports numerous integrations and combines no-code and low-code functionality to build advanced workflow structures.
This guide walks you through the process of installing and configuring n8n on Ubuntu 24.04 via Docker, setting up Nginx as a reverse proxy, and applying TLS certificates for secure access.
Prerequisites
Before proceeding, make sure you have the following:
- Access to a Ubuntu 24.04 server using a non-root user with sudo rights.
- A configured DNS A record pointing to your server’s public IP, such as n8n.example.com.
Install Docker and Docker Compose
Begin by updating your system packages.
console
$ sudo apt update
Install required packages needed for Docker repository management.
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
Add Docker’s official GPG key to your system.
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Register the Docker repository with your Ubuntu installation.
$ 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
Refresh the package index again.
$ sudo apt update
Install the Docker Engine, Docker CLI, and the Docker Compose plugin.
$ sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
Add your user to the docker group so Docker commands can be executed without sudo.
$ sudo usermod -aG docker $USER
Apply the updated group membership in your current session.
$ newgrp docker
Verify that Docker is working correctly.
$ docker --version
Create the n8n Directory Structure
This part explains how to set up a dedicated folder structure for n8n configuration and persistent data.
Create the base directory for n8n.
$ mkdir ~/n8n
Navigate into the created directory.
$ cd ~/n8n
Create a subfolder to store persistent n8n data.
$ mkdir n8n-data
Create a directory for storing local files used within workflows.
$ mkdir local-files
Because the n8n container operates under UID 1000, adjust file permissions accordingly.
$ sudo chown -R 1000:1000 n8n-data local-files
Configure Docker Compose for n8n
Now create the Docker Compose configuration for running n8n.
Create the docker-compose.yml file.
$ nano docker-compose.yml
Add the following configuration. Replace n8n.example.com with your domain.
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 exit the file once done.
This setup launches an n8n container with persistent storage, webhook support, and HTTPS-related environment variables.
Install and Configure Nginx
Nginx will serve as a reverse proxy that terminates HTTPS and routes traffic to the n8n container.
Install Nginx using the package manager.
$ sudo apt install nginx -y
Create a new Nginx server block. Replace the domain with your own.
$ sudo nano /etc/nginx/sites-available/n8n.example.com
Add this configuration, updating the domain accordingly.
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;
proxy_buffering off;
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
}
}
This configuration supports WebSockets and defines longer timeout values, suitable for n8n workflows.
Enable the site via a symbolic link.
$ sudo ln -s /etc/nginx/sites-available/n8n.example.com /etc/nginx/sites-enabled/
Check the Nginx configuration for errors.
$ sudo nginx -t
Reload Nginx to activate the configuration.
$ sudo systemctl reload nginx
Configure Firewall Rules
Set up firewall rules to allow required network traffic.
Permit HTTP traffic temporarily (required for certificate validation).
$ sudo ufw allow 80/tcp
Enable HTTPS to support secure connections.
$ sudo ufw allow 443/tcp
Install Certbot and Apply TLS Certificates
Certbot handles TLS certificate issuance and renewal via Let’s Encrypt.
Install Certbot and the Nginx plugin.
$ sudo apt install certbot python3-certbot-nginx -y
Request a certificate for your domain. Replace the domain and email address as needed.
$ sudo certbot --nginx -d n8n.example.com --email admin@example.com --agree-tos --non-interactive
Certbot updates your Nginx configuration to include TLS settings and ensures automated certificate renewal.
Test the renewal process.
$ sudo certbot renew --dry-run
If the dry run completes without errors, auto-renewal is correctly configured.
Start n8n
This section explains how to launch n8n using Docker Compose and verify that everything is functioning.
Move to the n8n directory.
$ cd ~/n8n
Start n8n in detached mode.
$ docker compose up -d
Check whether the container is running correctly.
$ docker compose ps
Inspect the container logs for successful initialization.
$ docker logs n8n
Sample Output:
…
n8n ready on https://n8n.example.com
Access and Configure n8n
Complete the setup by creating your admin account and adjusting initial settings.
Open your browser and visit:
https://n8n.example.com
Create your administrator profile by entering your name, email, and password.
Once logged in, you can use the n8n workflow editor to build automations.
Explore predefined templates or design your own workflow agent.
Manage the n8n Container
These commands help you manage your running n8n environment.
View Logs
Monitor real-time logs.
$ docker logs -f n8n
Stop n8n
Stop the container gracefully.
$ docker compose down
Restart n8n
Restart the n8n container.
$ docker compose restart
Update n8n
Upgrade to the newest n8n release.
$ docker compose pull
$ docker compose up -d
Conclusion
You have completed the installation of n8n on Ubuntu 24.04 with Docker, configured an Nginx reverse proxy, and added TLS encryption. Your n8n instance is now prepared to build automations. The containerized setup simplifies updates, maintenance, and scaling as your automation workload expands. For additional details, consult the official n8n documentation.


