Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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