NOSRV when upgraded to WebSocket?

I’ve got a Unifi Network Application behind HAProxy. Everything works fine when using the normal web interface, but when I use the Unifi app, HAProxy gives me trouble.

https~ black/<NOSRV> -1/-1/-1/-1/0 -1 0 - - PR-- 2/2/0/0/3 0/0 "GET /wss/s/default/events?clients=v2 HTTP/1.1"

When I ‘use_backend’ when hdr(Upgrade) -i WebSocket, the UNA works fine. However, the backend then ‘steals’ websocket traffic for other backends (Home Assistant iOS App and ESXi web-console).

I now have mitigated this by using the following:

use_backend unifi if { hdr(host) -i unifi } || { hdr(Upgrade) -i WebSocket } !{ hdr(host) -i esxi ha }

Why does this connection not match the normal host header ‘unifi’? Is there a better way to configure this? It’s a little weird to have to put all other websocket-servers in this line in order to make them work. And when I would encounter the same problem with another server I have no idea how to correct this.