How to made Websocket traffic to go via HAProxy

HAProxy Jan 28, 2021

The solution was simple: Tell HAProxy to tag Websocket traffic, and set up a separate but otherwise identical backend for this specific use case.

One of typical applications which is using Websocket traffic is Slack. An excelent opensource  alternative of it named Mattermost. The result looks something like this in the config file named haproxy.conf:

acl host_ws hdr_beg(Host) -i ws.
acl hdr_connection_upgrade hdr(Connection) -i upgrade
acl hdr_upgrade_websocket hdr(Upgrade) -i websocket
use_backend bk_ws_mattermost if host_ws { hdr(Host) -i }
use_backend bk_ws_mattermost if hdr_connection_upgrade hdr_upgrade_websocket { hdr(Host) -i }
use_backend bk_mattermost if { hdr(Host) -i }

backend bk_mattermost
server mattermost check

backend bk_ws_mattermost
server mattermost check

Here is a good article how to install Mattermost server on FreeBSD inside a jail.


Jordan Ostreff

2G/3G/4G/NSA-5G/SA-5G Mobile Packet Core, Telco Clouds, Ericsson CEE, OpenStack, NFV, Orchestration, SDN, Containerisation, Networking IPv4/IPv6, Industrial Computer Networks, Mathematics, Engineering

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Share with Me via Nextcloud