Would you mind having a look at my config below to see if anything incorrect jumps out at you? It seemed correct to me after reading over this thread and the n8n documentation. However, I realize I probably don’t need NODE_FUNCTION_ALLOW_EXTERNAL=moment,sugar-date
in both the docker-compose.yml and .env files, but I was experimenting to try to get it working.
You can see I have the modules installed:
And this is what my docker-compose.yml looks like. As you can see, I have defined the volumes for the modules in the n8n container as you have advised above.
version: "3"
services:
traefik:
image: "traefik"
restart: always
command:
- "--api=true"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
- "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
- "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
ports:
- "443:443"
volumes:
- ${DATA_FOLDER}/letsencrypt:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock:ro
n8n:
image: 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=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
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER
- N8N_BASIC_AUTH_PASSWORD
- N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_TUNNEL_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
- NODE_FUNCTION_ALLOW_EXTERNAL=moment,sugar-date
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${DATA_FOLDER}/.n8n:/home/node/.n8n
- /root/node_modules/sugar-core:/usr/local/lib/node_modules/sugar-core
- /root/node_modules/sugar-date:/usr/local/lib/node_modules/sugar-date
- /root/node_modules/moment:/usr/local/lib/node_modules/moment
and my .env
# Folder where data should be saved
DATA_FOLDER=/root/n8n/data/
# The top level domain to serve from
DOMAIN_NAME=domain.com
# The subdomain to serve from
SUBDOMAIN=sub
# DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from
# above example would result in: https://sub.domain.com
# The user name to use for autentication - IMPORTANT ALWAYS CHANGE!
N8N_BASIC_AUTH_USER=user
# The password to use for autentication - IMPORTANT ALWAYS CHANGE!
N8N_BASIC_AUTH_PASSWORD=passredacted
# Optional timezone to set which gets used by Cron-Node by default
# If not set New York time will be used
GENERIC_TIMEZONE=American/Chicago
# The email address to use for the SSL certificate creation
[email protected]
# Allow external NPM modules
NODE_FUNCTION_ALLOW_EXTERNAL=moment,sugar-date
Thank you!