> For the complete documentation index, see [llms.txt](https://docs.ionos.com/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/cloud/network-services/application-load-balancer/how-tos/configure-websocket.md).

# Configure WebSocket Support

IONOS CLOUD Application Load Balancer: configure WebSocket support for persistent connections

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:

1. [<mark style="color:blue;">Set up an ALB</mark>](/cloud/network-services/application-load-balancer/how-tos/setup-alb.md) either using the DCD or using the following API `POST` request.

```bash
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”]
}
```

2. Create a Target Group.
3. 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.
4. 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.
5. You can either create target group using the [<mark style="color:blue;">Create a Target Group</mark>](/cloud/network-services/application-load-balancer/how-tos/create-target-groups.md) or the following `POST` request.

```bash
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
      }
    ]
}
```

3. Create a [<mark style="color:blue;">Forwarding rule</mark>](/cloud/network-services/application-load-balancer/how-tos/setup-alb.md#add-forwarding-rules).

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:

```json
{
  “properties”: {
    “name”: “websocket-rule”,
    “protocol”: “HTTP”,
    “listenerIp”: “1.2.3.4”,
    “listenerPort”: 80,
    “httpRules”: [
      {
        “name”: “forward”,
        “type”: “FORWARD”,
        “targetGroup”: “<target group id>”
      }
    ]
}
```

{% hint style="info" %}
**Note**: Web Socket traffic differs from standard HTTP traffic, so ensure that your HTTP rules or conditions are accurate. Only the initial protocol upgrade to enable Web Socket tunneling can be targeted by the HTTP rule conditions. An example of this:
{% endhint %}

```json
{
 “httpRules”: [
      {
        “name”: “forward”,
        “type”: “FORWARD”,
        “targetGroup”: “<target group ID>“,
        “conditions”: [
          {
            “type”: “HEADER”,
            “condition”: “EQUALS”,
            “key”: “Connection”,
            “value”: “upgrade”
          },
          {
            “type”: “HEADER”,
            “condition”: “EQUALS”,
            “key”: “Upgrade”,
            “value”: “websocket”
          }
        ]
      }
    ]
}
```

{% hint style="success" %}
**Result:** The ALB can now handle HTTP protocol upgrade requests to switch to Web Socket tunneling.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ionos.com/cloud/network-services/application-load-balancer/how-tos/configure-websocket.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
