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.

I'm trying to set up a balanced cluster with mod_proxy_balancer.

I followed the example line from here to set a cookie. I have had to tweak it as the environment is not stable so not every request will return a 200 code.

Header always add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e;
<Proxy balancer://cluster>
    BalancerMember http://server1.example.com route=share2
    BalancerMember http://server2 example.com route=share1

</Proxy>
ProxyPass /balancer balancer://cluster/ stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse /balancer balancer://cluster/

(I know the stickysession != ROUTEID, but that is for reasons outside the scope of this question)

So on my local dev box I get

Set-Cookie  ROUTEID=.share1;

as one of the response headers, which is what I would expect.

However in the test environment, I get

 Set-Cookie: ROUTEID=.(null);

I don't know how it can be (null), and what I can do to stop it being null. Is there something the downstream server can do to stop the ROUTEID being set? Or is there some other config option which could be blocking it?

share|improve this question

2 Answers 2

I suspect you're accessing a URL outside of /balancer first, and getting a junk cookie from it (since the environment variable will indeed be null if there's no load balancer being used for the request).

Try just setting the cookie in cases where the balancer is used:

<Proxy balancer://cluster>
    BalancerMember http://server1.example.com route=share2
    BalancerMember http://server2 example.com route=share1
</Proxy>
<Location /balancer/>
    Header always add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e;
    ProxyPass balancer://cluster/ stickysession=JSESSIONID|jsessionid nofailover=On
    ProxyPassReverse balancer://cluster/
<Location>
share|improve this answer
    
I think that your answer is probably right in many cases but it wasn't the issue that I was having. –  Jeremy French Jul 24 '12 at 16:31
    
@JeremyFrench Nice, good find! Glad you've got it working. –  Shane Madden Jul 25 '12 at 0:11

In this particular case it was that the route was being set, but the response from the proxy server was failing. If it received an HTTP error it would give a response but if the connection was terminated it gave a null.

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.