HAProxy Enterprise Documentation 2.3r1

Syntax

You add one or more bind lines to your frontend and listen sections to receive client connections. Assign to it an IP address and port on which to listen.

In the following example, we define a frontend named myproxy and bind to the IP address 10.0.0.5 on port 80:

frontend myproxy
   bind 10.0.0.5:80
   # other settings not shown...

On some servers there may be more than one IP address assigned. If you wish to listen on a certain port, but don't care which IP address, then omit the address. In the following example, we receive traffic on any IP address assigned to the server at port 80:

frontend myproxy
   bind :80

The same frontend can listen on multiple IP addresses and/or ports, as shown below:

frontend myproxy
   bind :80
   bind :8080
   bind 127.0.0.1:9999

However, only one frontend can lay claim to a particular IP address and port. Once it has bound to it, other frontend and listen sections cannot bind to that same IP address and port combination.

You can also specify a range of ports. In the following example, the load balancer listens on any port between 2000 and 2100, inclusive:

frontend myproxy
   bind 10.0.0.5:2000-2100

The bind directive accepts IPv4 and IPv6 IP addresses.

To listen on all IPv6 addresses, specify ipv6@: before the port number.

frontend myproxy
   bind ipv6@:80

Data Plane API

Install the Data Plane API.

You can manage your binds remotely by calling the Data Plane API endpoint /services/haproxy/configuration/binds.

Get a list of binds in the fe_main frontend with the GET method:

$ curl -X GET \
    --user admin:adminpwd \
    "http://127.0.0.1:5555/v2/services/haproxy/configuration/binds?frontend=fe_main"

# output
{
   "_version":3,
   "data":[{
      "name":":80",
      "port":80
   }]
}

Add a bind to the fe_main frontend by using the POST method:

$ curl -X POST \
    --user admin:adminpwd \
    -H "Content-Type: application/json" \
    -d '{
       "name": "https",
       "address": "*",
       "port": 443,
       "alpn": "h2",
       "ssl": true,
       "ssl_certificate": "/etc/hapee-2.3/ssl/cert.pem"
    }' \
    "http://127.0.0.1:5555/v2/services/haproxy/configuration/binds?frontend=fe_main&version=2"

Get information about a specific bind by adding its name to the GET call:

$ curl -X GET \
    --user admin:adminpwd \
    "http://127.0.0.1:5555/v2/services/haproxy/configuration/binds/https?frontend=fe_main"

# output
{
   "_version":3,
   "data":{
      "address":"*",
      "alpn":"h2",
      "name":"https",
      "port":443,
      "ssl":true,
      "ssl_certificate":"/etc/hapee-2.3/ssl/cert.pem"
   }
}

Replace an existing bind by calling PUT:

$ curl -X PUT \
    --user admin:adminpwd \
    -H "Content-Type: application/json" \
     -d '{
       "address":"*",
       "alpn":"h2",
       "name":"https",
       "port":8443,
       "ssl":true,
       "ssl_certificate":"/etc/hapee-2.3/ssl/cert.pem"
     }' \
    "http://127.0.0.1:5555/v2/services/haproxy/configuration/binds/https?frontend=fe_main&version=3"

Delete a bind with the DELETE method:

$ curl -X DELETE \
    --user admin:adminpwd \
    "http://127.0.0.1:5555/v2/services/haproxy/configuration/binds/https?frontend=fe_main&version=4"

Next up

Bind Reference