0

I need loadbalancer configuration for the below topology, I tested the following configuration, but the "myappcluster1" section is always running. I cannot attached ProxyPass within section, it gives error ">>> ProxyPass cannot occur within section". I'm using Apache httpd-2.4.29-x64-vc11-r3 on windows 2012R2. How can do it this, thanks

<IfModule proxy_ajp_module>
<Proxy balancer://myappcluster1>
        BalancerMember ajp://Server1:8009 route=myapp1
        BalancerMember ajp://Server2:8009 route=myapp2
        BalancerMember ajp://Server3:8009 route=myapp3
</Proxy>
<Proxy balancer://myappcluster2>
        BalancerMember ajp://Server4:8009 route=myapp4
        BalancerMember ajp://Server5:8009 route=myapp5
</Proxy>
<Location "/myapp">
    # I tried these
    # <If "%{REMOTE_ADDR} -ipmatch '172.16.0.11'">
    # <If "-R '172.16.0.0/24'">
    <If "-R '172.16.0.11'"> 
        define clustername myappcluster2
        ProxyPass balancer://${clustername}/
    </If>
    <Else>
        define clustername myappcluster1
    </Else>
    ProxyPass balancer://${clustername}/
</Location>

LoadBalancer Topology

1 Answer 1

0

You can't define ProxyPass directives inside If directives.

So for this case specifically you probably need to use mod_rewrite instead. Also there is no need to use Location.

Change the whole Location to do what you seek, define this in virtualhost and it will even look simpler than what you just tried:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^172\.16\.0\.11
RewriteRule ^/myapp/(.*) balancer://myappcluster2/$1 [P,L]
RewriteRule ^/myapp/(.*) balancer://myappcluster1/$1 [P,L]

Explanation, if condition matches uses cluster2 else uses cluster1. Adjust as needed.

Note: You may need to add several ProxyPassReverse entries later on depending if the backend send redirections you need to change or not.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .