Deployment Overview of n8n on Server¶
Prerequisites and Basic Requirements¶
-
Operating System: Ubuntu 22.04 (Jammy)
-
Privileges: Root access is required to manage Docker and system directories.
-
Domain: A fully qualified domain name (FQDN) is required for SSL termination and routing.
-
Ports:
-
Port
80(HTTP) for initial SSL negotiation. -
Port
443(HTTPS) for secure application access. -
Port
5678(Internal) for the n8n service communication.
FQDN of the Final Panel¶
The application is accessible via the hostkey.in domain using the following format: n8n<Server ID>.hostkey.in
The service is exposed externally on port 443 via Traefik proxy.
File and Directory Structure¶
The deployment utilizes the following directory structure on the server:
-
/root/n8n-compose-file/: Contains the Docker Compose configuration file (compose.yml). -
/root/letsencrypt/: Stores SSL certificates and the ACME configuration file (acme.json). -
/root/.n8n/: Persists the n8n application data, workflows, and credentials. -
/root/local-files/: Stores local file uploads associated with n8n workflows. -
/data/: A general data directory created during setup.
Application Installation Process¶
The n8n application is deployed using Docker Compose. The deployment process includes:
-
Installation of the Docker Engine (specifically version
5:28.5.2-1~ubuntu.22.04~jammyon Ubuntu 22.04). -
Creation of the necessary directory structure.
-
Generation and execution of the
compose.ymlfile to launch services.
The specific image used for the n8n service is: docker.n8n.io/n8nio/n8n:latest
Docker Containers and Their Deployment¶
Two primary containers are deployed via Docker Compose:
-
Traefik:
-
Image:
traefik -
Purpose: Reverse proxy, SSL termination, and routing.
-
Configuration: Enabled Docker provider to auto-discover n8n via labels. Configured to redirect all HTTP traffic to HTTPS.
-
-
n8n:
-
Image:
docker.n8n.io/n8nio/n8n:latest -
Purpose: Executes the n8n workflow automation engine.
-
User: Runs as
root. -
Networking: Exposes port
5678only on the localhost interface (127.0.0.1), requiring the Traefik proxy for external access.
-
The deployment is managed by running docker compose up -d within the /root/n8n-compose-file directory.
Proxy Servers¶
Traefik acts as the reverse proxy for the application with the following configuration:
-
Entrypoints:
-
web: Listens on port80and redirects towebsecure. -
websecure: Listens on port443for HTTPS traffic. -
SSL/TLS:
-
Automatic certificate management via Let's Encrypt (ACME TLS Challenge).
-
Certificates are stored in
/letsencrypt/acme.jsonwithin the Traefik container volume. -
Email used for Let's Encrypt notifications:
[email protected]. -
Middleware:
-
Enforces SSL redirection.
-
Applies strict security headers (STS, XSS Filter, Content-Type Nosniff).
-
Sets the
SSLHostand includes subdomains/preload in the STS header. -
Routing Rules:
-
Routes traffic to the n8n service based on the
Hostheader matching the final domain. -
Maps the external request to the internal n8n port
5678.
Databases¶
-
Connection Method: n8n uses SQLite as the default database engine, stored within the application's persistent volume.
-
Storage Location: Database files are located inside the volume mounted at
/root/.n8n.
Access Rights and Security¶
-
File Permissions:
-
The directory
/root/n8n-compose-fileand/dataare owned byroot:rootwith permissions0750. -
The
compose.ymlfile has permissions0644. -
Firewall and Ports:
-
External access is restricted to ports
80and443via Traefik. -
The n8n container port
5678is bound strictly to127.0.0.1, preventing direct external access. -
Security Headers:
-
HTTP Strict Transport Security (HSTS) is enabled with a 10-year max-age.
-
Cross-site scripting (XSS) filtering is active.
-
Content-Type sniffing is disabled.
Location of Configuration Files and Data¶
-
Docker Compose File:
/root/n8n-compose-file/compose.yml -
n8n Data:
/root/.n8n(Mounts to/root/.n8ninside the container). -
Local Files:
/root/local-files(Mounts to/filesinside the container). -
SSL Certificates:
/root/letsencrypt(Mounts to/letsencryptinside the Traefik container).
Available Ports for Connection¶
| Port | Protocol | Description | Visibility |
|---|---|---|---|
| 80 | HTTP | Initial redirection to HTTPS | External (via Traefik) |
| 443 | HTTPS | Secure access to n8n UI and Webhooks | External (via Traefik) |
| 5678 | TCP | n8n Service Port | Internal only (127.0.0.1) |
Starting, Stopping, and Updating¶
Service management is performed using Docker Compose commands from the configuration directory:
-
Start or Restart Services:
-
Stop Services:
-
Update n8n Image: To pull the latest
latesttag and restart the container: -
View Logs: