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?
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:
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.