Tracking websocket sessions numbers based http headers in haproxy statistics

Hello all,

I have an haproxy in 1.5.18. I browsed all the documentation and did not find a solution for my issue. So I hope to find something here.

The context:

We have clients connecting to a frontend of the HAP.
These clients are connecting creating a Websocket (with Upgrade HTTP headers and so on).
I have an acl which forward them to a Websocket backend.

Here an example:

====
frontend inputflow
mode http
acl isws hdr(Upgrade) -i WebSocket
use_backend backws if isws
default_backend dfltback

backend backws
mode http
balance leastconn
server b1 server1:5566 check
server b2 server2:5566 check
server b3 server3:5566 check

====

What I’m looking for:

Clients are coming on frontend with an header “Authorization” with a specific value for each client.
I would like to track them and be able to know (for example through stats) how many connections there currently are for this or this Authorization header.

Some examples of Authorization header:

  • Authorization: Bearer a006d52004f7e7f028e0e62486f217ced1a6a0d5
  • Authorization: Bearer 3775e40fbea098e6188f598cce2a442eb5adfd2c
  • Authorization: Bearer e0f7efc3a358ccda25316047b351a4f0b5e0aa79

Wished results:

  • 3 WebSocket connections for a006d52004f7e7f028e0e62486f217ced1a6a0d5
  • 1 WebSocket connections for e0f7efc3a358ccda25316047b351a4f0b5e0aa79
  • 0 WebSocket connections for 3775e40fbea098e6188f598cce2a442eb5adfd2c

Thanks in advance for your help.

Regards