Press "Enter" to skip to content

HAProxy ( HA Proxy ) doc And HAproxy check – Cannot bind socket – How Dose it Work?

HAProxy (High-Availability Proxy) is a free, extremely fast, and dependable alternative written in C that provides high-availability load balancing and proxying for both TCP- and – HTTP-based applications.

Before we proceed to configure the proxy, then let us look into a few of the fundamental theories like ACLs, backends, and frontends from HAProxy Configuration.


Access Control List (ACL) is an evaluation requirement. Actions are performed depending on the end result of the test requirements, as an instance, choosing the host to forward the petition. The syntax of all ACL is acl acl <aclname> <criterion> [flags] [operator] [<value>] … as shown below.

cl acl_myApp path_sub myApp
  • Acl_myapp: The Title of This ACL.
  • Path_sub: A role that confirms if the request URL has app for a substring.


It can be a set of servers that process the forwarded requests. The backend consists of a load balancing algorithm along with a listing of servers with interfaces.

  • The basic syntax of this backend would be:
backend <backendname>
balance <loadbalancing algorithm>
server <name of the server> <ip>:<port> check
server <name of the server> <ip>:<port> check

Here’s a Good example with All the details filled in:

backend myAppBackend
balance roundrobin
server myAppServer1 check
server myAppServer2 check
  • MyAppBackend: The Title of the backend into the ACL will forward the Petition.
  • Roundrobin: The title of this load-balancing algorithm.
  • MyAppServer, myAppServer1: The title of this host.
  •, IP addresses of servers.
  • 8080: The interface on which server stinks.
  • Assess: Specifies to check the health of the host


The frontend defines the orders are forwarded to backends. It consists of a collection of IP addresses, including an interface, ACLs, and use_backend rules.

The syntax is:

frontend <frontend name>
    bind <IPs or wild card>:80
    acl <aclname> <criterion> [flags] [operator] [<value>] ...
    use_backend <backend name> if <aclname>

Here’s a Good example with All the details filled in:

frontend myAppFrontEnd
  bind *:80
  acl acl_myApp path_sub myApp
  use_backend myAppBackend if acl_myApp
  • myAppFrontEnd: Name of the frontend.

The frontend listens on interface 80 to each of the ports * accessible host. If the URL has myApp for a substring, then the petition is forwarded to myAppBackend. Otherwise, you’ll find no support accessible exclusion.

Statistics (Optional)

The tatistics record of HAProxy will demonstrate the status of their servers, the amount of relations, etc.. This can be enabled easily by adding the following configuration to the config file: