> For the complete documentation index, see [llms.txt](https://docs.glesys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.glesys.com/products/connectivity/load-balancer/how-tos/create-a-http-load-balancer.md).

# Create a HTTP load balancer

***

## Create a simple HTTP load balancer using the control panel

You create a load balancer by clicking on **Load balancers** in the left-hand menu under **Network**. Here, click on **Create load balancer**. The load balancer will be created under the currently active [project](/platform/control-panel/projects.md).

<figure><img src="/files/Y9W9poOoNiJyHSwGjvzG" alt=""><figcaption></figcaption></figure>

In the next dialog box, choose a name for the load balancer and specify the datacenter in which it will be located. Here, we choose the name *My-test-LB* and the data center in Falkenberg. Then, click on **Create**.

<figure><img src="/files/ogHF9xriPnbPfn2tsyB6" alt=""><figcaption></figcaption></figure>

Now you'll see an overview of the load balancer. Under the *Settings* section, you find the IP addresses for the load balancer—both an IPv4 address and an IPv6 address.

<div align="left"><figure><img src="/files/Nkq49D2YAeviCt6xw1Dr" alt=""><figcaption></figcaption></figure></div>

Right now, the load balancer has neither listeners nor servers to route traffic to. The first step is to create a listener. A listener is simply a port that listens for incoming traffic to the load balancer.

Scroll down to the *Listeners* section. Here, click on **Add Listener**.

<figure><img src="/files/C0xMacbre9Hhjin1BNy0" alt=""><figcaption></figcaption></figure>

Enter port 80 and select **http** under **Mode**. In the following [subsection](/products/connectivity/load-balancer/how-tos/create-a-http-load-balancer/create-a-https-load-balancer.md), we will cover certificates, but for now, we can skip that. Click **Save** to save the listener.

<figure><img src="/files/rsf50XrmrbDzxnDE3pEV" alt=""><figcaption></figcaption></figure>

Now you need to add targets—servers—that the load balancer can route traffic to. To do this, click the **Add Target** button located under the listener. Here, you can either enter the servers' IP addresses manually or select servers from the dropdown menu if they are running on Glesys.

<figure><img src="/files/MyoH3LGJBq4goGK51dkJ" alt=""><figcaption></figcaption></figure>

To add multiple servers, click **Add Target** again. Here, in this example, we select three servers hosted by Glesys. For *Port*, choose 80, the default port for HTTP. In this example, we also assign the same weight to all targets. This means the traffic will be evenly distributed among them. The higher the weight assigned to a target, the more traffic it will receive.

Ensure that all targets are marked as active. Targets that are not active will not receive any traffic.

<figure><img src="/files/qyhG0URJERY0ZPAZiigG" alt=""><figcaption></figcaption></figure>

If all the servers you specified as targets have an active web server listening on port 80, they will be marked as operational. A green dot will appear in front of these targets. The green dot indicates that the targets are functioning, active, and able to receive traffic.

<figure><img src="/files/tAG2uH6ThLMsifF7ss9p" alt=""><figcaption></figcaption></figure>

If any of the targets are not listening on port 80—or do not return a 200 or 300 HTTP status code—the target will be marked with a red dot instead. This indicates that the target will no longer receive any traffic. Targets that are not functioning are automatically removed from the load balancer.

### Testing the newly created load balancer

If all the targets are marked green, you can test whether traffic is evenly distributed between them by visiting the load balancer’s IP address and refreshing the page. The IP address can be found under the **Settings** section of the load balancer.

In this example, all servers have a simple webpage that displays the text *Web Server 1*, *Web Server 2*, or *Web Server 3*. Therefore, we can also test the distribution using a short script, such as:

{% code title="test-lb.sh" %}

```bash
#!/bin/bash
x=1
while [ $x -le 15 ]
do
  curl -s http://203.0.113.155 | grep "<title>"
  x=$(( $x + 1 ))
done
```

{% endcode %}

Running the script with `./test-lb.sh` will, in this example, output the following:

{% code title="Example output" %}

```terminal
  <title>Web Server 2</title>
  <title>Web Server 2</title>
  <title>Web Server 1</title>
  <title>Web Server 2</title>
  <title>Web Server 1</title>
  <title>Web Server 3</title>
  <title>Web Server 1</title>
  <title>Web Server 3</title>
  <title>Web Server 3</title>
  <title>Web Server 2</title>
  <title>Web Server 1</title>
  <title>Web Server 2</title>
  <title>Web Server 3</title>
  <title>Web Server 2</title>
  <title>Web Server 2</title>
```

{% endcode %}

If we had made more requests, the distribution among the targets would have become even more balanced.

For more information about targets' weights, see [Understand targets' weights](/products/connectivity/load-balancer/how-tos/understand-targets-weights.md). For more information about targets' health checks, see [Understand targets' health checks](/products/connectivity/load-balancer/how-tos/understand-the-targets-health-checks.md).

## Further guides

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Create a HTTPS load balancer</strong></td><td>Add an SSL certificate to your load balancer and have it serve HTTPS connections.</td><td><a href="/pages/PgFfDswbZSKu7A7AlLJ1">/pages/PgFfDswbZSKu7A7AlLJ1</a></td></tr><tr><td><strong>Log visitors' IP addresses and protocol</strong></td><td>By default, the target's web server log file only logs the load balancer's IP address. But you can use special headers to extract this information.</td><td><a href="/pages/n4coytNrDgwYHVPgAcnA">/pages/n4coytNrDgwYHVPgAcnA</a></td></tr><tr><td><strong>Use sticky sessions</strong></td><td>Sticky sessions are often necessary for applications such as web shops or websites that require user login.</td><td><a href="/pages/QvqBbBKtoM454f1D6py9">/pages/QvqBbBKtoM454f1D6py9</a></td></tr></tbody></table>

## Create a load balancer using the API

1. Use the [loadbalancer/create endpoint](https://github.com/GleSYS/API-docs/wiki/API-Documentation#loadbalancercreate) in the API to create a load balancer.&#x20;
2. To add a listener to the load balancer, use the [loadbalancer/addfrontend endpoint](https://github.com/GleSYS/API-docs/wiki/API-Documentation#loadbalanceraddfrontend).
3. To add a target (server) to the load balancer, use the [loadbalancer/addbackend endpoint](https://github.com/GleSYS/API-docs/wiki/API-Documentation#loadbalanceraddbackend).
4. To add a certificate to the listener for HTTPS traffic, use the [loadbalancer/addcertificate endpoint](https://github.com/GleSYS/API-docs/wiki/API-Documentation#loadbalanceraddcertificate).

Additional load balancer endpoints are available in the [loadbalancer module](https://github.com/GleSYS/API-docs/wiki/API-Documentation#loadbalancer-module).<br>


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.glesys.com/products/connectivity/load-balancer/how-tos/create-a-http-load-balancer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
