36

We have two Apache server as front-end and 4 tomcat server as back-end configured using mod_proxy module as load balancer. Now, we want to exclude an single tomcat url from the mod_proxy load balancer. Is there any way or rule to exclude?

Proxy Balancer Setting:

<Proxy balancer://backend-cluster1>
   BalancerMember http://10.0.0.1:8080 loadfactor=1 route=test1 retry=10
   BalancerMember http://10.0.0.2:8080 loadfactor=1 route=test2 retry=10
</Proxy>
Mughil
  • 1,989
  • 1
  • 20
  • 28

3 Answers3

54

You exclude paths from mod_proxy with an exclamation mark (!) before your full ProxyPass statement, which your sample is missing - It would look something like ProxyPass /path balancer://backend-cluster1. Therefore, to exclude a path, add:

ProxyPass /my/excluded/path !

before

ProxyPass /my balancer://backend-cluster1
Alastair McCormack
  • 2,203
  • 1
  • 16
  • 22
12

In addition to Alastair McCormack answer: If you use <Location>, you need to put the exception below instead of before:

<Location /my/>
    ProxyPass balancer://backend-cluster1
</Location>

<Location /my/excluded/path/>
    ProxyPass !
</Location>
frame
  • 121
-2

You could put a rewrite above the proxy directives that will give users a 404 error when they try to access the url you want to exclude. You will need to enable rewrite_module.

<Location ~ ^/urltoblock($|/)>
   RewriteEngine On 
   RewriteRule .* - [L,R=404]
</Location>
Pablo
  • 330