3

We are using Apache to load balance our backend (IIS) web servers. Our configuration follows an example from Apache doc. We try to achieve sticky routing (i.e. subsequent requests from the same client will be routed to the same upstream server) with a cookie set by Apache.

Our configuration looks like:

ProxyRequests off
ProxyPreserveHost On

<Proxy balancer://oursitename>
allow from all
BalancerMember http://1.2.3.4:80 route=1
# Further servers will be added here
ProxySet stickysession=ROUTEID
</Proxy>

# This line should set the correct cookie..
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED

ProxyPass /balancer-manager !
ProxyPass / balancer://oursitename/ nofailover=Off
ProxyPassReverse / http://1.2.3.4:80/

<Location /balancer-manager>
SetHandler balancer-manager
Order Deny,Allow
Allow from all
</Location>

Now Apache seems not to include the actual route, but the cookie does only contain the dot ".". I checked with Firebug and Wireshark. So in every HTTP response header appears (i.e. for each image/css/js):

Set-Cookie: ROUTEID=.; path=/

Surprisingly, when reloading the page about twice, suddenly there appears a Set-Cookie: ROUTEID=.2 in one of about ten responses. The browser uses this value in subsequent requests, which are then NOT acked by further Set-Cookie entries. So it seems like Apache accepts the route .2 as valid. I don't understand why it is always the .2, this number appears even if I remove the second server from the balancer!

Can anyone explain me what happens here and how I can fix it?

2
  • Did you ever find a solution for this? We just started seeing this same behavior (ROUTEID cookie set to "."). This had been working correctly but just in the last day we started seeing this behavior. I assume our configuration was modified but so far I have not been able to determine what changed or what could possibly cause BALANCER_WORKER_ROUTE to be empty.
    – nolt2232
    Jun 4, 2017 at 2:29
  • Hi, sorry, I don't know how that turned out. From comparing our config files I can only see that we have a route=vm1 now... Jun 5, 2017 at 15:59

2 Answers 2

1

I am not sure why it stays with 2. However part of your config is

Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED

env=BALANCER_ROUTE_CHANGED

will be 1 if the router has changed 0 otherwise, so if the route has not changed, then the cookie will not be set unless it needs to change to a new value.

0

It stays with 2 because you have set the stickysession that makes it stick to the current member server. Clear cache and refresh it should change (try this few times), and then stick to the new value until you delete cookies. To get better idea see https://wiki.apache.org/httpd/LoadBalanceWithoutStickyCookie

Thanks.

1
  • Hi, I am not sure if your answer fits to my question. You (and the link neither) do not explain e.g. how it is possible that the following string is received by the clients: Set-Cookie: ROUTEID=.; path=/ Apr 24, 2015 at 7:23

You must log in to answer this question.

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