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 slack.ostreff.info }
use_backend bk_ws_mattermost if hdr_connection_upgrade hdr_upgrade_websocket { hdr(Host) -i slack.ostreff.info }
use_backend bk_mattermost if { hdr(Host) -i slack.ostreff.info }

backend bk_mattermost
server mattermost 127.0.0.1:8065 check

backend bk_ws_mattermost
server mattermost 127.0.0.1:8065 check

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

Tags

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