Configure WebSocket Support
You can configure an ALB to support WebSockets, a communication protocol that provides full-duplex communication channels over a single TCP connection.
To configure WebSocket support follow these steps:
Set up an ALB either using the DCD or using the following API
POSTrequest.
curl -X POST -H ‘application/json’ -H ‘Authorization: Bearer ...’ https://api.ionos.com/cloudapi/v6/datacenters/{datacenterId}/applicationloadbalancers -d’
{
“properties”: {
“name”: “alb-websocket”,
“listenerLan”: 1,
“targetLan”: 2,
“ips”: [“1.1.1.1”],
“lbPrivateIps”: [“10.20.30.40/24”]
}Create a Target Group.
Before setting up an ALB, predefine a target group to distribute the incoming traffic to the correct target. An IP address and a port are used to register a target.
Ensure that no HTTP health check is configured for the target group for WebSocket support. Otherwise the ALB targets will be unavailable for load balancing. TCP health checks (healthCheckEnabled) are allowed.
You can either create target group using the Create a Target Group or the following
POSTrequest.
curl -X POST -H ‘application/json’ -H ‘Authorization: Bearer ...’ https://api.ionos.com/cloudapi/v6/targetgroups
{
“properties”: {
“name”: “websocket-target-group”,
“algorithm”: “ROUND_ROBIN”,
“protocol”: “HTTP”,
“targets”: [
{
“ip”: “10.20.30.100”,
“port”: 8080,
“weight”: 10,
“healthCheckEnabled”: true
}
]
}Create a Forwarding rule.
Forwarding rules define how client traffic is distributed to the targets. More than one rule can be created for the same load balancer.
Forwarding rule example:
Last updated
Was this helpful?