Haproxy mail config

I have a modoaba mail server running on IP .

When haproxy is bypassed , mail admin page loads just fine, but the problem is I want to use haproxy for my mail server, what configuration shall I include , please share examples.

When haproxy is used I get errors like :slight_smile: ERR_TOO_MANY_REDIRECTS , Bad Request (400)
https://mail.domain.com/ shows:
The page isnโ€™t redirecting properly

An error occurred during a connection to mail.domain.com.

This is how my haproxy is right now:

log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 20s
user haproxy
group haproxy
maxconn 2048

# Default SSL material locations
#ca-base /etc/ssl/certs
#crt-base /etc/ssl/private
    ca-base /etc/ssl
    crt-base /etc/ssl

# See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
    ssl-default-bind-ciphers xxxx
    ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
    ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets

log global
mode http
option httplog
option dontlognull
timeout connect 30s
timeout client 30s
timeout server 30s
timeout http-request 50s
timeout http-request 100s # Preventing Slowloris like attacks
option http-buffer-request
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http

frontend haprx01
bind ssl crt /etc/ssl/mailsym.prem crt /etc/ssl/sw.prem crt /etc/ssl/j.prem crt /etc/ssl/sym.prem crt /etc/ssl/larifanet.prem crt /etc/ssl/ticofds.prem alpn h2,http/1.1 ssl-min-ver TLSv1.2
mode http
bind abns@wp-haproxy-http accept-proxy

Redirect HTTP to HTTPS

redirect scheme https code 301 if !{ ssl_fc }
http-request deny if HTTP_1.0
http-request deny if { req.hdr(user-agent) -i -m sub curl phantomjs slimerjs }
http-request deny unless { req.hdr(user-agent) -m found }
http-request deny if { src -f /etc/haproxy/blacklist.acl }
acl whitelist src -f /etc/haproxy/whitelist.lst

ACL for โ€œmail.domain.comโ€

acl ACL_mailsym hdr(host) -i mail.domain.com
use_backend mailsym if ACL_mailsym

ACL for โ€œdomain.comโ€

acl ACL_sym hdr(host) -i domain.com www.domain.com
use_backend sym if ACL_sym

backend mailsym
stick-table type ip size 1m expire 10s store http_req_rate(10s)
tcp-request inspect-delay 10s
tcp-request content track-sc0 src

http-request deny if { sc_http_req_rate(0) gt 10 }

server mailsrv01 check

I have the webpage domain.com and the mail server as mail.domain.com, but haproxy has something wrong that is not forwarding the traffic correctly for each one.