0

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>
user811433
  • 3,999
  • 13
  • 53
  • 76

1 Answers1

0

Your balancer definitions are wrong. In the balancer definitions you just have to define the node, not the uri they handle.

**Incorrect:**
BalancerMember http://TOMCAT1:8080/APP

***Correct:***
BalancerMember http://TOMCAT1:8080

And then you handle uri-paths in ProxyPass

ProxyPass /app/ balancer://mycluster/app/


You can also use:

ProxyPass /app balancer://mycluster/app

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.

Daniel Ferradal
  • 2,727
  • 1
  • 13
  • 19
  • That worked like a charm! thank you. For the benefit of others, updated the question with the structure that worked for me – user811433 Aug 28 '17 at 20:30