HAProxy Enterprise Documentation 2.2r1

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 configurations such as TCP gateways.

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.

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

frontend myfrontend
   mode http
   bind :80
   bind :443 ssl crt /etc/hapee-2.2/certs/site.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-2.2/certs/site.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