Connection lost using Nginx reverse Proxy

Describe the problem/error/question

I can login N8N successfully but it showing connection lost in workflow editor when nginx reverse proxy enabled.

What is the error message (if any)?

Connection lost in Workflow Editor
You have connection issue or server is down, n8n should connect automatically once issue is resolved.

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Nginx configration

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-configmap
  namespace: n8n
data:
  default.conf: |
    server {
      listen 80;
      server_name n8n-cloud.kenntun.net;

      location / {
        return 301 https://$host$request_uri;
      }
    }

    server {
      listen 443 ssl;
      server_name n8n-cloud.kenntun.net;

      ssl_certificate /etc/nginx/ssl/n8n.crt;
      ssl_certificate_key /etc/nginx/ssl/n8n.key;

      location / {
        proxy_pass http://n8n-service.n8n.svc.cluster.local:15678;     
        proxy_set_header Connection '';
        chunked_transfer_encoding off;
        proxy_buffering off;
        proxy_cache off;
      }
    }
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: n8n
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-ipv4: 10.77.4.2
    service.beta.kubernetes.io/azure-load-balancer-internal: 'true'
spec:
  selector:
    app: nginx-n8n
  ports:
    - name: nginx-service-http
      protocol: TCP
      port: 80
      targetPort: 80
    - name: nginx-service-https
      protocol: TCP
      port: 443
      targetPort: 443
  type: LoadBalancer
apiVersion: v1
kind: ConfigMap
metadata:
  name: n8n-configmap
  namespace: n8n
data:
  # Database
  DB_TYPE: "postgresdb"
  DB_POSTGRESDB_DATABASE: "n8n"
  DB_POSTGRESDB_HOST: "postgres-service.n8n.svc.cluster.local"
  DB_POSTGRESDB_PORT: "5432"
  DB_POSTGRESDB_USER: "n8nadmin"
  
  # Deployment
  N8N_HOST: "n8n.kenntun.net"
  N8N_PORT: "15678"
  N8N_PROTOCOL: "http"
  N8N_DIAGNOSTICS_ENABLED: "false"
  N8N_DIAGNOSTICS_CONFIG_FRONTEND: ""
  N8N_DIAGNOSTICS_CONFIG_BACKEND: ""

  # Endpoint
  N8N_METRICS: "true"
  WEBHOOK_URL: "http://n8n-cloud.kenntun.net/"
  QUEUE_HEALTH_CHECK_ACTIVE: "true"
  
  # Logs
  N8N_LOG_LEVEL: "debug"
  N8N_LOG_OUTPUT: "console, file"
  N8N_LOG_FILE_COUNT_MAX: "100"
  N8N_LOG_FILE_SIZE_MAX: "32MB"
  
  # Nodes
  N8N_CUSTOM_EXTENSIONS: "/home/node/.n8n/nodes"
  
  # Task Runners
  N8N_RUNNERS_ENABLED: "true"
  N8N_RUNNERS_LAUNCHER_LOG_LEVEL: "info"
  NODE_FUNCTION_ALLOW_EXTERNAL: "*"
  
  # Timezone
  GENERIC_TIMEZONE: "Asia/Singapore"

  # External hooks
  EXTERNAL_FRONTEND_HOOKS_URLS: ""
  
  # User Management
  N8N_EMAIL_MODE: "smtp"
  N8N_SMTP_HOST: "smtp.kenntun.net"
  N8N_SMTP_PORT: "25"
  N8N_SMTP_SENDER: "[email protected]"
  N8N_SMTP_SSL: "false"
  N8N_SMTP_STARTTLS: "false"

Information on your n8n setup

  • n8n version: 1.92.2
  • Database (default: SQLite): PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Azure Kubernetes
  • Operating system: Ubuntu
1 Like

Hey,

So after doing some looking into it, it seems it might be because ure not handle websockets in ure nginx, I would look into these, which may help.

# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

# Forward original client info
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# Disable caching and buffering
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;

# Prevent timeouts
proxy_read_timeout 3600;
proxy_send_timeout 3600;

Hope this helps.
Samuel

2 Likes

This work for me.

1 Like

It works, million thanks

1 Like

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