My Profile Photo

Ionut Gavrilut


DevOps Enthusiast | Linux System Administrator | Certified Jenkins Engineer


Load Balancer Apache Configuration

This setup is for testing purposes. Do not open /balancer-manager path for anyone.

<VirtualHost *:80>
        ServerName 1.2.3.3
        RewriteEngine on
        RewriteRule ^(.*)$ https://1.2.3.3$1 [R=301,L]
</VirtualHost>
 
<VirtualHost *:443>
   ServerName 1.2.3.3
   LogFormat "%h %l %u %t \"%r\" %>s %b" common
   ErrorLog /var/log/httpd/test-ssl.error.log
   CustomLog /var/log/httpd/test-ssl.access.log combined
   SSLEngine on
   SSLCertificateKeyFile /etc/httpd/conf.d/cert/server.key
   SSLCertificateFile /etc/httpd/conf.d/cert/server.crt
   SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
 
 
   Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
   <Proxy balancer://mycluster>
      BalancerMember ajp://1.2.3.4:8009 route=node1
      BalancerMember ajp://1.2.3.5:8009 route=node2
      ProxySet stickysession=ROUTEID
      ProxySet lbmethod=byrequests
   </Proxy>
    
   <Location /balancer-manager>
      SetHandler balancer-manager
   </Location>
 
   ProxyPreserveHost On
   ProxyPass /balancer-manager !
   ProxyPass / balancer://mycluster/
   ProxyPassReverse / balancer://mycluster/
</VirtualHost>