WebSocket Not Connecting with n8n Behind OpenLiteSpeed Reverse Proxy (Docker Setup)

#1
Hi all,

I've deployed n8n (via Docker) on a VPS and placed it behind an OpenLiteSpeed (OLS) reverse proxy. The n8n editor loads at:

https://n8n.mydomain.com

However, I’m facing an issue with WebSocket connectivity. The browser console throws this error:


[WebSocketClient] Connection error:
WebSocket connection to 'wss://n8n.mydomain.com/rest/push?...' failed
Invalid WebSocket frame: RSV1 must be clear


What I’ve done so far:

n8n Docker .env:

Code:
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=*********
N8N_PROTOCOL=http
N8N_HOST=n8n.mydomain.com
N8N_PORT=5678
N8N_EDITOR_BASE_URL=https://n8n.mydomain.com
WEBHOOK_TUNNEL_URL=https://n8n.mydomain.com/
N8N_JWT_SECRET=*********
OpenLiteSpeed vhost config:

Code:
extProcessor n8n_backend {
  type                    proxy
  address                 http://127.0.0.1:5678
  maxConns                100
  initTimeout             60
  retryTimeout            10
  respBuffer              0
  persistConn             1
}

setEnvIf Request_URI "/rest/push" no-gzip
setEnvIf Request_URI "/rest/push" no-brotli

context /rest/push {
  type                    proxy
  handler                 n8n_backend
  uri                     /rest/push
  allowBrowse             1
  enableWebSocket         1

  extraHeaders            Connection: upgrade
  extraHeaders            Upgrade: websocket
  extraHeaders            Access-Control-Allow-Origin: *
}

context / {
  type                    proxy
  handler                 n8n_backend
  uri                     /
  allowBrowse             1
  enableWebSocket         1

  extraHeaders            Connection: upgrade
  extraHeaders            Upgrade: websocket
  extraHeaders            Access-Control-Allow-Origin: *
}

rewrite  {
  enable                  1
  rewriteCond             %{HTTPS} !=on
  rewriteRule             ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
}
Behavior:

  • HTTPS works fine
  • n8n editor loads
  • But /rest/push?... WebSocket fails to upgrade properly
  • docker logs n8n shows repeated: Invalid WebSocket frame: RSV1 must be clear


Screenshot 2025-07-02 at 2.32.10 PM.png Screenshot 2025-07-02 at 2.32.24 PM.png
 
Top