HAProxy Enterprise Documentation 1.8r2

Syntax

Use the server directive to define a server and its settings:

backend web_servers
   server web1 192.168.1.25:80 check

On each server line you specify:

  • a unique name, such as web1 in this example

  • the server's IP address and port

  • optional parameters, such as check

One of the most common settings is check, which enables HAProxy Enterprise to send health check probes to the server at an interval. If a connection can't be made to a server, it will be removed from the load-balancing rotation.

If you find yourself repeating the same parameters on every server line, you can move them to a default-server line. Any parameters on a default-server line apply to the server lines in the same section. In the following example, we use the default-server directive to apply the check parameter to all servers:

backend web_servers
  default-server check
  server web1 192.168.1.25:80
  server web2 192.168.1.26:8080
  server web3 192.168.1.27:8080

By default, connections are sent to servers in a roughly equal distribution. However, if you add a weight parameter, you can cause more traffic to be sent. Servers with higher weight values receive more traffic:

backend web_servers
  default-server check
  server web1 192.168.1.25:80 weight 10
  server web2 192.168.1.26:8080 weight 10
  server web3 192.168.1.27:8080 weight 20

The maximum value for weight is 256.


Next up

Server Reference