I have noticed that a match made in heaven is Proxmox with HAProxy. HAProxy provides high-availability load balancing for the Proxmox VE web management UI across a multi-node cluster. However, placing a Proxmox cluster behind a round-robin proxy often breaks NoVNC WebSocket (WSS) console connections. I noticed this only after putting my cluster behind HAProxy. There are a few gotchas with HAProxy and Proxmox that I discovered.
Without session persistence, requests are routed across different Proxmox nodes mid-session, invalidating authentication tickets and causing NoVNC WebSocket handshakes to fail.
HAProxy TLS termination and source/cookie stick-table routing pinning Proxmox authentication tickets and NoVNC WebSocket streams to the same backend node.
Fixing Options
There are three approaches to resolving NoVNC WebSocket routing across a Proxmox VE cluster:
- Only using a single backend.
- Switch away from round-robin mode.
- Tweaking Proxmox HAProxy backends to allow for HAProxy to keep the same backend used during the browser session.
I could not use option #1 because that would defeat the point of HAProxy running above Proxmox.
I could not go with option #2 as I wanted to have more users and load-balance according to the user logged in.
So, I decided to go with option #3. I implemented this option with HAProxy and sticky cookie sessions.
After installing HAProxy on Ubuntu (see the installation guide here. ), configure the frontend to route traffic to the proxmox backend:
default_backend proxmox
HAProxy Cookie Fix
Next, configure session persistence in the proxmox backend so HAProxy pins each browser session to a consistent Proxmox cluster node: You will want to add the following portion to your backend settings:
cookie SERVERID insert indirect nocache
You will also need to add in the setting to the actual backend to allow for a cookie. Here is an example of the server backend:
server proxmox-nuc3 192.168.1.14:8006 maxconn 501 cookie S3 check ssl verify none
Full Backend Configuration
Combining health checks, forwarded headers, and sticky session cookies yields the complete HAProxy backend configuration:
backend proxmox
description Back-end proxmox
mode http
balance roundrobin
option forwardfor
option httpchk GET /
cookie SERVERID insert indirect nocache
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
server proxmox-nuc1 192.168.1.12:8006 cookie S1 check ssl verify none
server proxmox-nuc2 192.168.1.13:8006 cookie S2 check ssl verify none
server proxmox-nuc3 192.168.1.14:8006 cookie S3 check ssl verify none
Verification
With sticky cookie insertion enabled, the Proxmox VE web UI and NoVNC console remain accessible even if an individual hypervisor node goes offline for maintenance.
As shown below, NoVNC WebSocket sessions establish cleanly through HAProxy across reboots, browsers, and cluster nodes without WSS timeouts:
Originally published by James Farr Gomez on Nertwork.



Top comments (0)