Self-Hosting n8n with Docker and Nginx Proxy Manager on Ubuntu
This guide explains how to deploy n8n with Nginx Proxy Manager (NPM) using Docker Compose on a new Ubuntu server. The setup uses a shared Docker network so that NPM can route traffic to n8n securely with HTTPS.
1. Prerequisites
- Ubuntu 22.04 or later server (root or sudo access).
- A domain name managed through a registrar or shared hosting provider.
- Docker and Docker Compose installed.
Install Docker and Compose
sudo apt update && sudo apt upgrade -y
curl -fsSL https://get.docker.com | sh
sudo apt install docker-compose-plugin -y
sudo usermod -aG docker $USERLog out and back in after adding your user to the Docker group.
2. DNS Record Setup
Create a DNS record with your registrar or hosting provider so that the domain or subdomain points to your server’s public IP.
Example for a subdomain:
- Type: A
- Name:
n8n - Value:
your-server-ip
In this example, the full address will be n8n.example.com resolving to your server’s IP.
This step is required so that Nginx Proxy Manager can generate a valid SSL certificate.
3. Free Subdomain Providers
If you do not have a paid domain name, you can use a free subdomain service. These services allow you to register a subdomain and point it to your server’s public IP:
Once you have registered a subdomain, create an A record pointing it to your server’s IP address. You can then use that subdomain in place of n8n.example.com in the configuration.
4. Cloud Provider Firewall Rules
Some cloud providers, including Oracle Cloud, block ports by default.
For Nginx Proxy Manager to work, you must ensure the following ports are open in your cloud firewall/security group:
- TCP 80 (HTTP)
- TCP 81 (Nginx Proxy Manager admin panel)
- TCP 443 (HTTPS)
This applies to Oracle Cloud and any other provider with restricted port access.
5. Create a Shared Docker Network
docker network create shared6. Setup Project Directory
mkdir ~/n8n-docker && cd ~/n8n-docker
nano docker-compose.ymlPaste the following configuration:
services:
n8n:
image: docker.n8n.io/n8nio/n8n:latest
container_name: n8n
restart: always
ports:
- "5678:5678"
volumes:
- n8n_data:/home/node/.n8n
environment:
N8N_HOST: 0.0.0.0
N8N_PORT: 5678
WEBHOOK_URL: https://n8n.example.com/
VUE_APP_URL_BASE_API: https://n8n.example.com/
networks:
- shared
nginx-proxy-manager:
image: jc21/nginx-proxy-manager:latest
container_name: nginx-proxy-manager
restart: always
ports:
- "80:80"
- "81:81"
- "443:443"
volumes:
- data:/data
- letsencrypt:/etc/letsencrypt
networks:
- shared
networks:
shared:
external: true
volumes:
n8n_data:
data:
letsencrypt:Replace n8n.example.com with your actual domain or subdomain.
Save and exit.
7. Start Containers
docker compose up -dCheck that both containers are running:
docker ps8. Access Nginx Proxy Manager
Open your browser and go to http://your-server-ip:81.
Default login credentials:
- Email:
[email protected] - Password:
changeme
Change them immediately.
9. Configure Proxy Host for n8n
- Log in to Nginx Proxy Manager.
- Go to Hosts → Proxy Hosts → Add Proxy Host.
- Fill in:
- Domain Names:
n8n.example.com - Scheme:
http - Forward Hostname/IP:
n8n - Forward Port:
5678 - Enable Cache Assets and Block Common Exploits.
- In the SSL tab:
- Request a new certificate from Let’s Encrypt.
- Enable Force SSL and HTTP/2 Support.
Save settings.
10. Verify n8n
Visit: https://n8n.example.com — n8n should now be available over HTTPS.
At this stage, you have n8n running behind Nginx Proxy Manager with HTTPS enabled. You can use either a paid domain or a free subdomain service, as long as you can control the DNS records and point them to your server.