1.Install docker
yum install docker
systemctl enable docker
systemctl start docker
2. Run haproxy docker images with with persistent volume
mkdir /opt/haproxy
#and move the haproxy.cfg inside /opt/haproxy
docker run -d -p 8888:8888 -p 8404:8404 -v /opt/haproxy:/usr/local/etc/haproxy:Z haproxy
3. haproxy.cfg
global
daemon
maxconn 256
defaults
timeout connect 10s
timeout client 30s
timeout server 30s
log global
mode http
option httplog
maxconn 3000
frontend stats
bind *:8404
stats enable
stats uri /stats
stats refresh 10s
frontend app1
bind *:80
default_backend app1_backend
backend app1_backend
server server1 192.168.0.151:8080 maxconn 32
server server1 192.168.0.152:8080 maxconn 32
server server1 192.168.0.153:8080 maxconn 32
docker-compose file
version: '3'
services:
haproxy:
image: haproxy
ports:
- 80:80
- 8404:8404
volumes:
- /opt/haproxy:/usr/local/etc/haproxy