HAProxy Enterprise Documentation 1.8r2

Listen

A listen section can be used to define a complete proxy with the functions of a frontend and backend combined. The listen section is well suited whenever you need to route traffic to a specific set of servers or for non HTTP-related configuration such as TCP gateways.

Each listen keyword is followed by a label, such as www.example.com, to differentiate it from others.

listen www.example.com
    # proxy configuration

If you need to split traffic towards separate pools of servers or your application is getting larger then it's better to use distinct frontend and backend sections.

Listen configuration examples

The following configuration sample defines frontend myfrontend that accepts incoming connections on ports 80 and 443, and forwards all traffic to the pool of servers defined on the web_servers backend.

frontend myfrontend
   mode http
   bind :80
   bind :443 ssl crt /etc/hapee-1.8/certs/ssl.pem
   http-request redirect scheme https unless { ssl_fc }
   default_backend web_servers

backend web_servers
   mode http
   balance roundrobin
   option httpchk
   server s1 192.168.1.25:80 check
   server s2 192.168.1.26:8080 check

The same result can also be achieved by using a listen section that combines all of the configuration directives used in the sample above.

listen fe_main
   # frontend configuration settings
   mode http
   bind :80
   bind :443 ssl crt /etc/hapee-1.8/certs/ssl.pem
   http-request redirect scheme https unless { ssl_fc }

   # backend configuration settings
   balance roundrobin
   option httpchk
   server s1 192.168.1.25:80 check
   server s2 192.168.1.26:8080 check

Next up

Defaults