Configuring Proxmox VE NoVNC Consoles Behind HAProxy with Sticky Sessions

Configuring Proxmox VE NoVNC Consoles Behind HAProxy with Sticky Sessions

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 Sticky Session Routing for Proxmox VE NoVNC Consoles
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:

  1. Only using a single backend.
  2. Switch away from round-robin mode.
  3. 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:

haproxy
default_backend proxmox

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:

cli
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:

cli
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:

haproxy
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:

Share of working proxmox through haproxy

>_ Engineering Discussion 4 Comments

+ Add Field Note ↓
  1. Awesome stuff — this HAProxy backend configuration really helped me get our multi-node Proxmox VE cluster console proxy running cleanly behind a single wildcard TLS certificate!

  2. Thank you very much, that's exactly what I was looking for! Adding the WebSocket upgrade ACL and tunnel timeout in HAProxy fixed our Proxmox VNC console disconnects immediately. Thanks again :)

  3. ↗ Proxmox HAProxy SSL Configuration — Al's Knowledge Base Cross-Reference

    […] Reference guide for proxying Proxmox VE web UI and noVNC WebSocket traffic through HAProxy […]

  4. ↗ Enterprise Networking Trends: Automation, Whitebox & Cloud — Nertwork Cross-Reference

    […] Previously we walked through configuring Proxmox VE VNC WebSocket consoles behind HAProxy with SSL offloading […]

Leave a Technical Comment

Share CLI tips, hardware notes, or questions below. Inline backticks (`command`) are supported.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Engineering Notes