0

I set the LoadBalancer in Apache 2.4.6 (CentOS), it works well except one thing.

When the user open the alias of Apache server, it anytime redirect the user to another server when click somewhere on website, which is not good for me. I would like to set the Apache in this way:

If someone open the page (and the Apache load the webpage from one server), stay here, and doesn't redirect to another server, if he/she click on somewhere on website.

How can I configure the Apache in this way?

The current configuration is this below:

<Proxy balancer://mycluster>
        BalancerMember https://server1:443
        BalancerMember https://server2:443
        Require all granted
        ProxySet lbmethod=bytraffic
</Proxy>
<Location /balancer-manager>
        SetHandler balancer-manager
        Require host example.org
 </Location>
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/

I tried this configuration as well, but still not working as expected:

ProxyPass "/test" "balancer://mycluster" stickysession=JSESSIONID|jsessionid scolonpathdelim=On
<Proxy "balancer://mycluster">
    BalancerMember "https://server1:443" route=node1
    BalancerMember "https://server2:443" route=node2
Require all granted
</Proxy>


<Location /balancer-manager>
        SetHandler balancer-manager
        Require host example.org
</Location>
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/
1

That sounds like your backend doesn't set jsessionid cookies? The docs suggest to start from the following example if your backend doesn't set cookies itself:

Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
<Proxy "balancer://mycluster">
    BalancerMember "http://192.168.1.50:80" route=1
    BalancerMember "http://192.168.1.51:80" route=2
    ProxySet stickysession=ROUTEID
</Proxy>
ProxyPass        "/test" "balancer://mycluster"
ProxyPassReverse "/test" "balancer://mycluster"

(Note the explicit Header add Set-Cookie.)

  • Works well, thanks a lot! – Feriman Apr 3 at 14:31

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.