This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ===== HA Proxy ===== ==== Install ==== <code> yum install haproxy </code> ==== Configure ==== Edit /etc/haproxy/haproxy.cfg <code> 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 </code> Execute: <code> systemctl enable haproxy systemctl start haproxy firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=https firewall-cmd --reload </code> ==== Configure rsyslog ==== Edit /etc/rsyslog.conf <code> # 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 </code> Execute: <code> systemctl restart rsyslog </code> ==== Subdomain configuration ==== Edit /etc/haproxy/haproxy.cfg <code> 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 </code> ==== Enable stats ==== Edit /etc/haproxy/haproxy.cfg <code> listen stats bind *:9000 stats enable stats uri / stats refresh 5s stats auth cmorun:Manager20. </code> Execute: <code> firewall-cmd --permanent --add-port=9000/tcp </code> ==== Upgrade to HA Proxy 1.8 ==== <code> yum-config-manager --enable rhel-server-rhscl-7-rpms yum install rh-haproxy18 </code> You can use this commando to enable in the session: <code> scl enable rh-haproxy18 bash </code> You need to change the file /etc/opt/rh/rh-haproxy18/haproxy/haproxy.cfg to reflect changes. Execute: <code> systemctl disable haproxy systemctl stop haproxy systemctl enable rh-haproxy18-haproxy systemctl start rh-haproxy18-haproxy </code> ==== 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