0

Given a balancer which currently proxies all requests:

<Proxy balancer://java-app>
    ProxySet lbmethod=bybusyness
    BalancerMember https://java1:8443 route=java-app1
    BalancerMember https://java2:8443 route=java-app1
 </Proxy>
 ProxyPass / balancer://java-app/ stickysession=JSESSIONID|jsessionid scolonpathdelim=On

I need to modify it so that: When the query string contains parameter p1 Then It should proxy to the balancer Otherwise it should not proxy

mod-proxy cannot be used for this use case. We need to use mod-rewrite bu I can't figure how to achieve this goal effectively.

Thanks in advance, - Nestor

0

Here is what I ended up doing. A rewrite condition triggers the rewrite rule to pass through all requests containing the parameter p1 in the query string to the /restless endpoint. This endpoint does not exist in the server but it is just used to balance the request via the Proxy:

RewriteCond %{QUERY_STRING} ^.*p1=.*$
RewriteRule (.*)$ /restless$1 [PT] 

<Proxy balancer://java-app>
    ProxySet lbmethod=bybusyness
    BalancerMember https://java1:8443 route=java-app1
    BalancerMember https://java2:8443 route=java-app1
</Proxy>

ProxyPass /restless balancer://krfs-app stickysession=JSESSIONID|jsessionid scolonpathdelim=On

  • You can use mod_rewrite to proxy to a balancer configuration by using something like RewriteRule (.*) balancer://java-app/$1 [P] – bodgit Mar 8 '16 at 23:12
  • Thanks bodgit, the question is if you can still specify parameters for that balancer like to use sticky session? – Nestor Urquiza Mar 9 '16 at 18:12
  • You can set them with the ProxySet directive at the same time as the lbmethod that you're already doing. – bodgit Mar 13 '16 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.