Because this seems the first hit on Google for HA and HAProxy I want to share something I recently had problems with. My connection to HA worked but the WebSocket connection was not possible.
It seems the WebSocket tries to connect to the same host but always with the port added to the request.
This results in HAProxy not able to direct the request to the designated backend if you just have an acl like this:
acl hass-acl hdr(host) -i SUBDOMAIN.DOMAIN.COM
I added a second acl:
acl hass-acl443 hdr(host) -i SUBDOMAIN.DOMAIN.COM:443
and then
use_backend hass-backend if hass-acl || hass-acl443
and WebSocket connections started to work…