===== HA Proxy ===== ==== Install ==== yum install haproxy ==== Configure ==== 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 ==== Configure rsyslog ==== 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 ==== Subdomain configuration ==== 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 ==== Enable stats ==== 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 ==== Upgrade to HA Proxy 1.8 ==== 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 ==== References ==== * https://www.serverlab.ca/tutorials/linux/network-services/layer-4-load-balancing-with-haproxy/ * https://www.haproxy.com/blog/introduction-to-haproxy-logging/ * https://blog.entrostat.com/routing-multiple-domains-using-haproxy-http-and-https-ssl/ * https://freedif.org/redirect-a-subdomain-to-a-vm-with-haproxy