Haproxy for SMTP loadbalance / Haproxy untuk loadbalance mail server

Haproxy for SMTP loadbalance / Haproxy untuk loadbalance mail server

ip haproxy   10.10.0.10
ip mail 1      10.10.0.122
ip mail 2      10.10.0.123

on debian 8
#apt-get install  haproxy
#haproxy -v

newer package haproxy
#echo "deb http://httpredir.debian.org/debian jessie-backports main" | \
      sudo tee /etc/apt/sources.list.d/backports.list
#apt-get update
#apt-get install -t jessie-backports haproxy
#haproxy -v

Enable loging
edit /etc/rsyslog.conf
# provides UDP syslog reception
$ModLoad imudp
$UDPServerAddress 127.0.0.1
$UDPServerRun 514
add
if ($programname == 'haproxy') then -/var/log/haproxy.log


restart rsyslog
#systemctl restart rsyslog.servic

Configuring the load balancer 
edit /etc/haproxy/haproxy.cfg
tambahkan

##enable port 25 ##
frontend ft_smtp
      bind *:25
      mode tcp
      default_backend bk_postfix
backend bk_postfix
     mode tcp
     server postfix1 10.10.0.122:25 check
     server postfix2 10.10.0.123:25 check

## enable port 465 ##
frontend smtp-465
     bind :465
     mode tcp
     maxconn 128
     default_backend backend-smtp-465
backend backend-smtp-465
    mode tcp
    server mail1 10.10.0.122:465 check maxconn 128
    server mail2 10.10.0.123:465 check maxconn 128

## enable port 995
frontend smtp-995
    bind 0.0.0.0:995
    mode tcp
    maxconn 128
    default_backend backend-smtp-995
backend backend-smtp-995
    mode tcp
    server mail1 10.10.0.122:995 check maxconn 128
    server mail2 10.10.0.123:995 check maxconn 128

## enable stats ##
listen stats 0.0.0.0:9000
        mode http
        stats enable
        stats uri /stats
        stats realm HAProxy\ Statistics
        stats auth admin:admin
## enable stats for ver 1.8.xx ## 
#listen stats
#        bind :9000
#        mode http
#        stats enable
#        stats uri /stats
#        stats realm HAProxy\ Statistics
#        stats auth admin:admin


#service haproxy restart

Komentar

Postingan populer dari blog ini

Cloudflared argo tunnel zero trust service on Mikrotik

Migrasi zimbra ke zimbra dengan rsync

Squid Proxy ssl bump untuk transparent HTTPS #2