Sticky Session with an assignable backend

Lasse Karstensen lasse.karstensen at
Tue Oct 23 13:18:52 CEST 2012

Oddur Snær Magnússon:
> I have a problem where I need to be able to do "sticky session" based on some identity, but be able to tell varnish which identity belongs to which backend.
> In my case, I have a value in the request header(oauth token) which should always go to the same backend. I begin by sending the request to a random backend, and if the users session does not live on that backend I get X-Accel-Redirect header back telling me which backend that request should go to.  I can easily do that part using a restart and send the request to the correct one.
> But  from then on I want to remember that that specific identity should always go to that given backend.

Given that the HTTP client supports it, I'd just put the backend information
into a client side cookie. 

Send a set-cookie in deliver, and extract/remove it in recv on the next

Lasse Karstensen
Varnish Software AS

More information about the varnish-misc mailing list