I configured the haproxy with 2 backends for ports 80 and 443.
Here is the part for these:-
defaults
mode tcp
========================
frontend secure
bind *:443
default_backend secure
frontend insecure
bind *:80
default_backend insecure
=================
And Backends:-
backend secure
balance source
server <IP_Address>:443 check
server <IP_Address>:443 check
backend insecure
balance source
server <IP_Address>:80 check
server <IP_Address>:80 check
==============================
[root@ocplbnext01 ~]# systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; preset: disabled)
Active: active (running) since Wed 2024-08-21 15:30:16 EEST; 12h ago
Process: 100653 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -f $CFGDIR -c -q $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 100657 (haproxy)
Tasks: 9 (limit: 203835)
Memory: 14.2M
CPU: 7min 44.875s
CGroup: /system.slice/haproxy.service
├─100657 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/conf.d -p /run/haproxy.pid
└─100660 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/conf.d -p /run/haproxy.pid
Aug 22 03:28:34 ocplbnext01 haproxy[100660]: [WARNING] (100660) : Server insecure/ is DOWN, reason: Layer4 connection problem, info: “Connection refused”, check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining>
Aug 22 03:28:34 ocplbnext01 haproxy[100660]: [ALERT] (100660) : backend ‘insecure’ has no server available!
Aug 22 03:28:45 ocplbnext01 haproxy[100660]: [WARNING] (100660) : Server secure/ is UP, reason: Layer4 check passed, check duration: 0ms. 1 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
Aug 22 03:28:46 ocplbnext01 haproxy[100660]: [WARNING] (100660) : Server insecure/ is UP, reason: Layer4 check passed, check duration: 0ms. 1 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
Aug 22 03:32:53 ocplbnext01 haproxy[100660]: [WARNING] (100660) : Server secure/ is UP, reason: Layer4 check passed, check duration: 0ms. 2 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
Aug 22 03:32:54 ocplbnext01 haproxy[100660]: [WARNING] (100660) : Server insecure/ is UP, reason: Layer4 check passed, check duration: 0ms. 2 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
Aug 22 03:33:33 ocplbnext01 haproxy[100660]: [WARNING] (100660) : Server secure/ is DOWN, reason: Layer4 connection problem, info: “Connection refused”, check duration: 0ms. 1 active and 0 backup servers left. 1 sessions active, 0 requeued, 0 remaining i>
Aug 22 03:33:34 ocplbnext01 haproxy[100660]: [WARNING] (100660) : Server insecure/ is DOWN, reason: Layer4 connection problem, info: “Connection refused”, check duration: 0ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining>
Aug 22 03:33:46 ocplbnext01 haproxy[100660]: [WARNING] (100660) : Server secure/ is UP, reason: Layer4 check passed, check duration: 0ms. 2 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
Aug 22 03:33:46 ocplbnext01 haproxy[100660]: [WARNING] (100660) : Server insecure/ is UP, reason: Layer4 check passed, check duration: 0ms. 2 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
~
~