n8n is a node-based workflow automation tool. It lets you connect different applications, services and databases so they can communicate with each other without having to develop a complex application from scratch.
The easiest way to install n8n on Clouding is to create a server from our Docker image and install n8n on it using the instructions below.
Requirements
- A cloud server created from our Docker image.
Create a .env file
Connect to the newly created Docker server via SSH as root and create a directory to store your n8n environment configuration file and the corresponding Docker Compose files:
# mkdir /opt/n8n-compose
# cd /opt/n8n-compose Inside the n8n-compose directory, create a file named .env to customize your n8n installation. This is just a basic example; you should adapt it to your specific needs:
# DOMAIN_NAME and SUBDOMAIN determine where n8n will be accessible
# The 'top level' domain it will be accessible from:
DOMAIN_NAME=ejemplo.com
# Subdomain it will be accessible from:
SUBDOMAIN=n8n
# With the values above, n8n will be accessible at: https://n8n.ejemplo.com
# Optional: time zone used by Cron and other scheduled task nodes
# If nothing is specified, the default time zone is New York
GENERIC_TIMEZONE=Europe/Berlin
# Email address to use to create the TLS/SSL certificate
SSL_EMAIL=user@ejemplo.comCreate the local files directory
Inside the n8n-compose directory, create a directory named local-files to share files between the n8n instance and the host system (for example, for use with the Read/Write Files from Disk node):
mkdir local-files
Create the Docker Compose file
Create the compose.yaml file. Add the following content:
services:
traefik:
image: "traefik"
restart: always
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
- "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
- "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
volumes:
- traefik_data:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock:ro
n8n:
image: docker.n8n.io/n8nio/n8n
restart: always
ports:
- "127.0.0.1:5678:5678"
labels:
- traefik.enable=true
- traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
- traefik.http.routers.n8n.tls=true
- traefik.http.routers.n8n.entrypoints=web,websecure
- traefik.http.routers.n8n.tls.certresolver=mytlschallenge
- traefik.http.middlewares.n8n.headers.SSLRedirect=true
- traefik.http.middlewares.n8n.headers.STSSeconds=315360000
- traefik.http.middlewares.n8n.headers.browserXSSFilter=true
- traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
- traefik.http.middlewares.n8n.headers.forceSTSHeader=true
- traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
- traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
- traefik.http.middlewares.n8n.headers.STSPreload=true
- traefik.http.routers.n8n.middlewares=n8n@docker
environment:
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- N8N_RUNNERS_ENABLED=true
- NODE_ENV=production
- WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
- TZ=${GENERIC_TIMEZONE}
volumes:
- n8n_data:/home/node/.n8n
- ./local-files:/files
volumes:
n8n_data:
traefik_data:The Docker Compose file above configures two containers: one for n8n and another to run traefik, a proxy that handles routing and TLS/SSL certificates.
It also creates and mounts two Docker volumes and mounts the local-files directory you created earlier:
| Name | Type | Mount point | Description |
| n8n-data | Volume | /home/node/.n8n | Where n8n stores its SQLite database file and encryption key. |
| traefik_data | Volume | /letsencrypt | Where Traefik stores TLS/SSL certificate data. |
| ./local-files | Bind | /files | A local directory shared between the n8n instance and the host. In n8n, use the /files path to read from and write to this directory. |
Run Docker Compose
Start n8n by running:
# docker compose up -d
To stop the containers, type:
# docker compose stop
Conclusion
You can now access your n8n installation using the subdomain + domain combination you defined in the configuration file .env. With the configuration in this article, this would be https://n8n.ejemplo.com.
n8n is only accessible via HTTPS, not HTTP.
We hope this tutorial has helped you 🙂. Remember, if you have any questions about this or anything else related to your servers on Clouding, feel free to write to soporte@clouding.io We're here to help with whatever you need. Get in touch!