haproxy - Basic TCP Proxy
Oct 30, 2015

haproxy is a high performance TCP/HTTP load balancer. I’ve been using it for years now and have never experienced any problems with it. There are loads more configurable options but this simple config below will get you started.

The below configuration is for haproxy 1.5. I have not tested it with anything newer. Version 1.5 is what comes with Debian 8 (jessie).

global
        user haproxy
        group haproxy
        daemon
        maxconn 4096

defaults
        mode    tcp
        balance leastconn
        timeout client      30000ms
        timeout server      30000ms
        timeout connect      3000ms
        retries 3

frontend fr_server1
        bind 0.0.0.0:<port>
        default_backend bk_server1

backend bk_server1
        server srv1 <ip>:<port> maxconn 2048

To use this configuration, execute the following command:

haproxy -f <config path>

This will run haproxy in the background as a daemon.

haproxy Related
    Comments