I have apache 2.4 setup with mod_proxy to load balance 2 tomcats. Here is the addition to httpd.conf
ProxyRequests Off
ProxyPass /APP balancer://mycluster stickysession=JSESSIONID|jsessionid
ProxyPassReverse /APP balancer://mycluster
<Proxy balancer://mycluster>
BalancerMember http://TOMCAT1:8080/APP route=TOMCAT1
BalancerMember http://TOMCAT2:8080/APP route=TOMCAT2
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Require all granted
</Location>
ProxyPass /balancer-manager !
<Location /server-status>
SetHandler server-status
Require host localhost
Require all granted
</Location>
From a browser if I try "http://localhost:7000/APP" it does not work. However if I use "http://localhost:7000/APP/" the application comes up.
Note the additional "/" and the end of the url. How can this additional / be avoided?
Update Working structure:
ProxyRequests Off
ProxyPass /APP balancer://mycluster/APP stickysession=JSESSIONID|jsessionid
ProxyPassReverse /APP balancer://mycluster/APP
<Proxy balancer://mycluster>
BalancerMember http://TOMCAT1:8080 route=TOMCAT1
BalancerMember http://TOMCAT2:8080 route=TOMCAT2
</Proxy>
<Location /balancer-manager>
SetHandler balancer-manager
Require all granted
</Location>
ProxyPass /balancer-manager !
<Location /server-status>
SetHandler server-status
Require all granted
</Location>
Your balancer definitions are wrong. In the balancer definitions you just have to define the node, not the uri they handle.
And then you handle uri-paths in ProxyPass
You can also use:
Note: balancer://mycluster is the same as balancer://mycluster/. And there is a rule you should follow to avoid issues that says if source has a trailing slash target should also have a trailing slash, that way you avoid path mismatches in the response from the backend.
Note2: Your
<Location /server-status>
has two Require statements, since the default is Require any, all will be allowed because you have a Require all granted, so makes no sense to define a Require host localhost in that context.