Hi,

I've been playing with the idea of adding support for the proxy module to add stickysession cookies on behalf of the backend servers. I have one case on my hands right now where this would be needed, and I can think of this being of use for others too.

The way this would work is that if the proxy would see a response from a backend to which no LB cookie was received either from the client or the backend, a new cookie would be injected to the response. If the cookie already exists, nothing would be done. The cookie when added would be based on the balancer and member-name of the current worker

Before I start hacking at the code, I'd like to confirm a few things.

To start with, am I correct in assuming that others might find use for this feature? Should I do this, what are my chances of seeing the feature added to a future 2.2.x release?

By the way, is it just me, or is the current documentation on how the stickysession feature works quite a bit confusing? From the docs I at least understand it so that it would be possible to use any generic session-id based cookie (whether it's PHPSESSION, JSESSIONID or something else). However, both trying this in practice and looking through the code gives a rather different view - the format of the stickysession cookie appears to be very strict, having to match the balancer-name and the route defined for the BalancerMember.

Regardless, back to the subject. I've been going through the proxy code, and while it's by no means a simple module, adding this functionality doesn't look too difficult. My current plan to attack this would be roughly:

- Add a "setsticky=Off/On" parameter to ProxyPass / ProxySet
- In ap_proxy_http_process_response, add the necessary code to check if the cookie exists, and if not, add it. This could likely happen somewhere near ap_proxy_read_headers. Moving get_cookie_param from mod_proxy_balancer.c to proxy_util.c would allow to reuse it here.

Any thoughts and/or comments?

Cheers,
Jani

Reply via email to