Nginx docker linux config + custom node module

adding this , cause it took me quite a while to get it set up and fix all the error .

setup is n8n installed inside docker n8n:versiopn 1.26. then nginx in host linux machine to point to docker instance


server {
    listen 80;
    listen [::]:80;
    return 301 https://$host$request_uri;

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    ssl_certificate /etc/ssl/domain.pem;
    ssl_certificate_key /etc/ssl/domainkey.pem;
    location / {
        proxy_pass http://localhost:5678/;
        proxy_set_header Connection '';
        proxy_http_version 1.1;
        chunked_transfer_encoding off;
        proxy_buffering off;
        proxy_cache off;
        proxy_set_header Upgrade $http_upgrade; 
        proxy_set_header Connection "upgrade";


version: "3"
      context: .
      dockerfile: Dockerfile
    image: n8nio/n8n
    restart: always
    container_name: n8n
      - ""
      - N8N_EMAIL_MODE=smtp
      - N8N_SMTP_USER=xxx
      - N8N_SMTP_PASS=xxx
      - N8N_SMTP_SENDER=xxx
      - N8N_BASIC_AUTH_USER=xxx
      - N8N_PORT=5678
      - WEBHOOK_URL=
      - GENERIC_TIMEZONE=Asia/Kolkata
      - /home/path/n8n/data:/home/node/.n8n
      - /home/path/n8n/files:/files


FROM n8nio/n8n
npm install axios -g
npm i moment -g
1 Like

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

A couple of changes I would make…

N8N_BASIC_AUTH_USER and N8N_BASIC_AUTH_PASSWORD are not used anymore so they can be removed.

With the nginx config for the SSL location you only need…

location / {
    proxy_set_header Connection 'Upgrade';
    proxy_set_header Upgrade $http_upgrade;
    proxy_http_version 1.1;

We do use Moment and Axios already so you shouldn’t need to build an image for that but to be complete I would do

FROM n8nio/n8n
USER root
npm install axios -g
npm install moment -g
USER node

Then in your compose file in the environment variables you would need to add NODE_FUNCTION_ALLOW_EXTERNAL and list the external packages that can be used. For internal NodeJS functions you can set NODE_FUNCTION_ALLOW_BUILTIN

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.