Reliable, high performance TCP/HTTP load balancer. See homepage at http://www.haproxy.org/.

HAProxy is a simple and fast load-balancer. For HTTP it works quite similar to 'pound' or Nginx. It can also load-balance plain TCP connections which enables it handle many more protocols like SSH, the Git protocol, SMTP, IMAP and many more.

Installation

HAProxy can simply be installed using pakfire. You will find the configuration files in /etc/haproxy.

Configuration

You can find a very good and detailed configuration manual on the official HAProxy homepage at http://www.haproxy.org/#docs.

Example 1: SMTP Failover

This example will make HAProxy listen on port 25 and forward all connections to the first SMTP server (smtp01) until this is either offline or has more than 1000 connections opened. After that HAProxy will switch to the second one until a limit of 1000 concurrent connections is reached as well.

global
    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        nobody
    group       nobody
    daemon

    stats socket /var/lib/haproxy/stats

defaults
    log                     global
    option                  redispatch
    retries                 3
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout check           10s
    maxconn                 3000

listen smtp :25
    mode tcp
    option tcplog
    balance first

    server smtp01 192.168.180.101:25 check maxconn 1000
    server smtp02 192.168.180.102:25 check maxconn 1000