Configuring Round Robin Load Balancing by Using HAProxy
The following example uses HAProxy to implement a front-end server that balances incoming requests between two backend web servers, and which also handles service outages on the backend servers.
The following figure shows an HAProxy server (10.0.0.10
), which is
connected to an externally facing network (10.0.0.0/24
) and to an
internal network (192.168.1.0/24
). Two web servers,
websrv1
(192.168.1.71
) and
websrv2
(192.168.1.72
), are accessible on the
internal network. The IP address 10.0.0.10
is in the private address
range 10.0.0.0/24
, which can't be routed on the Internet. An upstream
Network Address Translation (NAT) gateway or a proxy server provides access to and from
the Internet.
Figure 2-1 Example HAProxy Configuration for Load Balancing

By combining the load balancing capability of HAProxy with the high-availability capability of Keepalived, you can configure a backup load balancer that ensures continuity of service if the primary load balancer fails. See Enhancing Load Balancing by Using Keepalived With HAProxy for more information on how this configuration can be extended.