Self hosted n8n (docker) with nginx for SSL

Hi everyone, new joiner of the n8n community (first post). Currently deploying n8n in a docker container with an existing nginx (using npm which includes certs management).
I’ve been trying several configuration tricks (with webhook, trust-proxy-ip-header, etc), but I always end up on the same error:

Connection lost

in my running n8n instance running on https:// n8n.myserver.synology.me

Configuration to know

Server type: NAS
Docker: several containers including n8n, npm (nginx+certbot)
DNS registered: myserver.synology.me
nginx config: proxy host n8n.myserver.synology.me and cert configure to force SSL connection to it (and working >> all traffic from http:// goes to https:// n8n.myserver…

n8n docker-compose

version: '3.7'

services:
  # The n8n application service.
  n8n:
    image: n8nio/n8n:latest
    container_name: n8n_app
    restart: always
    ports:
      - 5678:5678
    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}
      - N8N_PROXY_HOPS=1
      - VUE_APP_URL_BASE_API=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - WEBHOOK_TUNNEL_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
    volumes:
      - n8n_data:/home/node/.n8n
      - ./local-files:/files
    networks:
      - web-proxy

volumes:
  n8n_data:

networks:
  web-proxy:
    external: true

Note that an .env file (same folder as docker-compose) contains the SUBDOMAIN, DOMAIN_NAME etc.
web-proxy network is the default one on which npm (nginx) is running as well.

Investigation so far

My n8n docker logs shows no specific error:

Initializing n8n process
n8n ready on ::, port 5678
n8n Task Broker ready on 127.0.0.1, port 5679
[license SDK] Skipping renewal on init: license cert is not due for renewal
Registered runner “JS Task Runner”
Version: 1.106.3
Editor is now accessible via: https:// n8n.myserver…

(node:7) [DEP0060] DeprecationWarning: The util._extend API is deprecated. Please use Object.assign() instead.
(Use node --trace-deprecation ... to show where the warning was created)

My nginx docker logs shows no specific issue either.

I can successfully access my n8n instance via https (and web browser states that the connection is secure and certificates are valid).

However, the Connection lost remains in the n8n interface workflows.
And when I want to create a workflow, I can’t obviously execute any step as “connection to server lost”. Interestingly, I still managed to connect my n8n instance to Google Cloud API (with OAuth) to access one of their service I want to automate. Connection from https:// n8n.myserver… to Google APIs is successful.

Happy to hear some of your thoughts about this. Thanks

Found the root cause. Thanks to the Deep learning AI module of n8n Docs AI btw.

The “Connection lost” error in the n8n workflow tab when running behind Nginx Proxy Manager (NPM) is almost always caused by missing or misconfigured WebSocket support in your reverse proxy setup. n8n relies on WebSockets for real-time updates in the UI, and if these are not properly proxied, you’ll see this error.

Therefore, go to npm (nginx proxy manager) and enable WebSockets support and you are good to go!