Search code examples
apacheload-balancingmod-proxy

mod_proxy isn't using the port defined in my balancermembers


I'm trying to set up my apache load balancer to proxy to the same backend clusters to apps running on different ports. The cluster definitions are like this:

<Proxy balancer://wordpress-cluster>
    BalancerMember http://192.168.2.10:80
    BalancerMember http://192.168.2.11:80
</Proxy>
<Proxy balancer://corporate-cluster>
    BalancerMember http://192.168.2.10:81
    BalancerMember http://192.168.2.11:81
</Proxy>

In the load balancer, one of the vhost needs to talk to both, so in the vhost definition I have:

ProxyRequests Off
ProxyPreserveHost Off
SSLProxyEngine On

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass /feed balancer://wordpress-cluster/feed lbmethod=byrequests
ProxyPassReverse /feed balancer://wordpress-cluster/feed

ProxyPass / balancer://corporate-cluster/ lbmethod=byrequests
ProxyPassReverse / balancer://corporate-cluster/

when requesting for '/' , I get the content served from the port 80 app, not the port 81 app.

Would anyone know on what is happening? it looks like this might be a case of overzealous worker sharing, but shouldn't specifying the different ports prevent that?

Is there something else I should do?

Forgot to mention: this is using apache 2.2.4-1 on a centos box.

Thanks in advance! Tim


Solution

  • OK, so I still don't know what happened. Did 2 steps to fix my problem: 1) split the cluster into 2 1-machine clusters and things worked:

    <Proxy balancer://wordpress-cluster>
        BalancerMember http://192.168.2.10:80
    </Proxy>
    <Proxy balancer://corporate-cluster>
        BalancerMember http://192.168.2.11:81
    </Proxy>
    

    But of course that killed balancing and failover support... not good

    Second option, create dns aliases to ensure that the balancermembers looked different (even though they point to the same boxes:

    <Proxy balancer://wordpress-cluster>
        BalancerMember http://192.168.2.10:80
        BalancerMember http://192.168.2.11:80
    </Proxy>
    <Proxy balancer://corporate-cluster>
        BalancerMember http://corp01:81
        BalancerMember http://corp02:81
    </Proxy>
    

    And voila! The setup is now working for me :)