sudo apt install haproxy
sudo mv /etc/haproxy/haproxy.cfg{,-ori}
root@mail:~# mv /etc/haproxy/haproxy.cfg{,-ori}
root@mail:~#

Buat konfigurasi haproxy sebagai berikut

global
    log /dev/log local0
    log /dev/log local1 notice
    chroot /var/lib/haproxy
    stats socket /var/run/haproxy.stat
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

defaults
    log global
    mode    tcp
    option tcplog
    timeout connect 5000ms
    timeout client  50000ms
    timeout server  50000ms

frontend pop3_frontend
    bind *:996 ssl crt /etc/haproxy/ssl/sertifikat.pem
    acl is_pop3 dst_port 996
    use_backend pop3_backend if is_pop3

backend pop3_backend
    server pop3_server mail.wachid.web.id:995 check ssl verify none


frontend smtp_frontend
    bind *:466 ssl crt /etc/haproxy/ssl/sertifikat.pem
    acl is_smtp dst_port 466
    use_backend smtp_backend if is_smtp

backend smtp_backend
    server smtp_server mail.wachid.web.id:465 check ssl verify none


frontend imap_frontend
    bind *:994 ssl crt /etc/haproxy/ssl/sertifikat.pem
    acl is_imap dst_port 994
    use_backend imap_backend if is_imap

backend imap_backend
    server imap_server mail.wachid.web.id:993 check ssl verify none

Buat directory dan sertifikat ssl

sudo mkdir /etc/haproxy/ssl
sudo nano /etc/haproxy/ssl/sertifikat.pem

Menguji konfigurasi haproxy

sudo haproxy -d -f /etc/haproxy/haproxy.cfg

Menjalankan service haproxy

sudo systemctl start haproxy
sudo systemctl status haproxy

Mengenable haproxy pada startup

systemctl enable haproxy

Leave a Reply

Your email address will not be published. Required fields are marked *