Thank you Christian!
The solution of Christian is correct! Basically you have to put ProxyPass and ProxyPassReverse inside the configuration for the Virtualhosts, and defined the Proxy-Directive in the proxy.conf. As Christian already stated in his own comments, it is required use the ProxySet-Directive inside the Proxy-Directive to set the StickySessions - it won't work with ProxyPass.
Sample VirtualHost (one for foo, bar, baz):
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName customer-foo.company.tld ServerAlias customer-foo-balancer customer-foo.company.tld www.customer-foo.company.tld DocumentRoot /var/www/foo <Directory /> Options FollowSymLinks AllowOverride None Order allow,deny deny from all </Directory> <Directory /var/www/foo/wcs_static> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> <Directory /var/www/foo/wcs_static_res> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> # maintenance RewriteEngine On RewriteCond %{DOCUMENT_ROOT}/wcs_static_res/maintenance.html -f RewriteCond %{REQUEST_FILENAME} !/wcs_static_res/maintenance.html RewriteCond %{REQUEST_FILENAME} !/wcs_static_res/maintenance-time.png RewriteCond %{REMOTE_HOST} !^10\.1\.0\.203 RewriteRule ^.*$ /wcs_static_res/maintenance.html [L] # redirect, SSL itself is handled by another server in front of this loadbalancer RedirectMatch (.*)/$ https://customer-foo.company.tld/wcs/ui # load balancer # web-frontend ProxyPass /wcs balancer://foo # stickysession can't be set with ProxyPass in this case, see proxy.conf ProxyPassReverse /wcs balancer://foo # standalone-clients ProxyPass /wcs_service balancer://fooservice ProxyPassReverse /wcs_service balancer://fooservice # logging LogLevel warn ErrorLog ${APACHE_LOG_DIR}/foo_error.log CustomLog ${APACHE_LOG_DIR}/foo_access.log combined </VirtualHost>
proxy.conf (there is only this one):
<IfModule mod_proxy.c> ProxyRequests Off ProxyVia Off ProxyPreserveHost On <Proxy balancer://foo> # stickysessions must be defined here ProxySet failonstatus=503 stickysession=JSESSIONID|jsessionid nofailover=Off scolonpathdelim=On BalancerMember ajp://10.171.23.120:8010/wcs lbset=0 route=foo001 loadfactor=40 BalancerMember ajp://10.171.23.121:8010/wcs lbset=0 route=foo002 loadfactor=40 BalancerMember ajp://10.171.23.122:8010/wcs lbset=0 route=foo003 loadfactor=20 </Proxy> <Proxy balancer://fooservice> ProxySet failonstatus=503 stickysession=JSESSIONID|jsessionid nofailover=Off scolonpathdelim=On BalancerMember ajp://10.171.23.120:8011/wcs_service route=foo001 loadfactor=40 BalancerMember ajp://10.171.23.121:8011/wcs_service route=foo002 loadfactor=40 BalancerMember ajp://10.171.23.122:8011/wcs_service route=foo003 loadfactor=20 </Proxy> <Proxy balancer://bar> ProxySet failonstatus=503 stickysession=JSESSIONID|jsessionid nofailover=Off scolonpathdelim=On BalancerMember ajp://10.171.21.110:8010/wcs lbset=0 route=bar001 loadfactor=40 BalancerMember ajp://10.171.21.111:8010/wcs lbset=0 route=bar002 loadfactor=40 BalancerMember ajp://10.171.21.112:8010/wcs lbset=0 route=bar003 loadfactor=20 </Proxy> <Proxy balancer://barservice> ProxySet failonstatus=503 stickysession=JSESSIONID|jsessionid nofailover=Off scolonpathdelim=On BalancerMember ajp://10.171.21.110:8011/wcs_service route=bar001 loadfactor=40 BalancerMember ajp://10.171.21.111:8011/wcs_service route=bar002 loadfactor=40 BalancerMember ajp://10.171.21.112:8011/wcs_service route=bar003 loadfactor=20 </Proxy> <Proxy balancer://baz> ProxySet failonstatus=503 stickysession=JSESSIONID|jsessionid nofailover=Off scolonpathdelim=On BalancerMember ajp://10.171.45.100:8010/wcs lbset=0 route=baz001 loadfactor=40 BalancerMember ajp://10.171.45.101:8010/wcs lbset=0 route=baz002 loadfactor=40 BalancerMember ajp://10.171.45.102:8010/wcs lbset=0 route=baz003 loadfactor=20 </Proxy> <Proxy balancer://bazservice> ProxySet failonstatus=503 stickysession=JSESSIONID|jsessionid nofailover=Off scolonpathdelim=On BalancerMember ajp://10.171.45.100:8011/wcs_service route=baz001 loadfactor=40 BalancerMember ajp://10.171.45.101:8011/wcs_service route=baz002 loadfactor=40 BalancerMember ajp://10.171.45.102:8011/wcs_service route=baz003 loadfactor=20 </Proxy> </IfModule>
proxy_balancer.conf:
<IfModule mod_proxy_balancer.c> <IfModule mod_status.c> <Location /balancer-manager> SetHandler balancer-manager Order deny,allow Deny from all # store here your internal IPs for direct access Allow from 127.0.0.1 ::1 Satisfy all </Location> </IfModule>
Now you can change the configuration through http://ipofloadbalancer.com/balancer-manager for all servers behind your proxy. No need to hack with /etc/hosts on the clients and the loadbalancer. Drawback, especially with the Apache 2.4, the interface gets quickly cluttered and you have to scroll much.