yum install haproxy
Edit /etc/haproxy/haproxy.cfg
frontend apache mode tcp bind 172.19.65.206:80 default_backend apache-servers backend apache-servers balance roundrobin mode tcp server apache1 172.19.65.207:80
Execute:
systemctl enable haproxy systemctl start haproxy firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=https firewall-cmd --reload
Edit /etc/rsyslog.conf
# Provides UDP syslog reception $UDPServerAddress 127.0.0.1 $ModLoad imudp $UDPServerRun 514 # Save logs for haproxy global configs local2.* /var/log/haproxy.log # Save logs for haproxy lapoc frontend local0.* /var/log/haproxy-apache.log
Execute:
systemctl restart rsyslog
Edit /etc/haproxy/haproxy.cfg
frontend lapoc log 127.0.0.1 local0 debug option httplog option forwardfor mode http bind 172.19.65.206:80 acl apache_sub hdr(host) -i apache.gbmdc.dc acl tomcat_sub hdr(host) -i tomcat.gbmdc.dc use_backend apache-servers if apache_sub use_backend tomcat-servers if tomcat_sub backend apache-servers mode http option httplog option forwardfor server apache1 172.19.65.207:80 backend tomcat-servers mode http option httplog option forwardfor server tomcat1 172.19.65.207:8080
Edit /etc/haproxy/haproxy.cfg
listen stats bind *:9000 stats enable stats uri / stats refresh 5s stats auth cmorun:Manager20.
Execute:
firewall-cmd --permanent --add-port=9000/tcp
yum-config-manager --enable rhel-server-rhscl-7-rpms yum install rh-haproxy18
You can use this commando to enable in the session:
scl enable rh-haproxy18 bash
You need to change the file /etc/opt/rh/rh-haproxy18/haproxy/haproxy.cfg to reflect changes.
Execute:
systemctl disable haproxy systemctl stop haproxy systemctl enable rh-haproxy18-haproxy systemctl start rh-haproxy18-haproxy