Skip to main content

HAProxy

URLs

Installation

# RedHat 8.3
yum install haproxy

Setting Up HAProxy Logging

The default configuration points to the localhost (127.0.0.1) and local2 is the default facility code used to identify HAProxy log messages under rsyslog.

/etc/rsyslog.d/haproxy.conf

$ModLoad imudp
$UDPServerAddress 127.0.0.1
$UDPServerRun 514
local2.*        /var/log/haproxy/haproxy-traffic.log
local2.notice   /var/log/haproxy/haproxy-admin.log

Create the directories required

mkdir /var/log/haproxy

Restart the rsyslog

systemctl restart rsyslog

Configuring HAProxy

Edit the file /etc/haproxy/haproxy.cfg .

HAProxy Stats page

listen stats
    bind *:9000
    stats enable
    stats hide-version
    stats uri /stats
    stats admin if LOCALHOST
    stats auth haproxy:Lostp@1ss

AP Servers

listen apservers_20013
    bind *:20013
    mode tcp
    timeout client  10800s
    timeout server  10800s
    option tcp-check
    balance roundrobin
    server tpemimsaw00 10.10.2.33:20013 check
    server tpemimsaw01 10.10.2.32:20013 check

Restart the haproxy

systemctl restart haproxy