Hello community,
Currently I've installed Varnish 2.0.6 and I'm using a cluster of Web Servers.
In order to find a work around the session clustering issue, I thought
implement session stickiness as part of the load balancing configuration, so
all subsequent requests from the same user would go to the same webserver and
so ensure the session information consistency. But as I know, Varnish don't
have integrated support to Stickiness, and therefore I have to delegate this
function to a Load Balancer. Through this infrastructure the client requests
would follow the below path:
User Agent --> Load Balancer Public VIP --> One of the Varnish Servers --> (IF
cache hit --> deliver cached content to Client ) ELSE ( Load Balancer Private
VIP --> One of the Web Servers)
To support sticky sessions my Load Balancer uses the Arrow Point cookie
mechanism which, to be brief, add a cookie named ARPT that identified the user
session. And according to the above path, Varnish sends requests and receive
responses from the Load Balancer private VIP which needs that the cookie in
question be passed transparently to and from the client. So, Varnish should
take care of this cookie in two ways: the Cookie header in the incoming
requests and the Set-Cookie in the responses from the Load Balancer.
What do you recommend me to do?. I have ideas but I don't sure. For example, to
extract the desired cookie from Cookie header I'm doing the following:
### Code Start ####
vcl_receive {
...
if (req.http.Cookie ~ "ARPT=") {
set req.http.LB-Cookie = regsub(req.http.Cookie, ".*(ARPT=[^;]+).*",
"\1");
}
unset req.http.Cookie;
...
}
sub vcl_miss {
set bereq.http.Cookie = req.http.LB-Cookie;
}
sub vcl_pass {
set bereq.http.Cookie = req.http.LB-Cookie;
}
### Code End ####
To keep it in the http response, I guess:
### Code Start ###
sub vcl_fetch {
...
if (obj.http.Set-Cookie ~ "ARPT=") {
#Save Set-Cookie, so it can be used in vcl_deliver
set obj.http.X-Set-Cookie = obj.http.Set-Cookie;
}
...
}
sub vcl_deliver {
if (obj.hits > 0) {
...
} else {
#It was a cache miss
...
#Set back Set-Cookie header in case it's set
if (resp.http.X-Set-Cookie){
set resp.http.Set-Cookie = resp.http.X-Set-Cookie;
unset resp.http.X-Set-Cookie;
}
}
}
### Code End ###
I don't know how to extract a cookie from a Set-Cookie header, but I tried with
this code:
obj.http.LB-Cookie = regsub(obj.http.Set-Cookie,
".*(ARPT=[^;]+(;[^=]+=[^;]+)*).*", "\1");
Nevertheless, it appears don't work fine.
Am I in the right way? Is there a better solution?
Thank you in advance.
---------------------------------------------------
Bayron Guevara
Web Programmer
[email protected]
Grupo OPSA
Barrio Guamilito 3ra. Avenida 6 y 7 calle, No.34
PBX:(504) 553 3101, Ext:3213, Cel:9987-8669
San Pedro Sula, Honduras, C.A.
AVISO DE CONFIDENCIALIDAD: Este e-mail contiene informacion que es confidencial
y solo puede ser utilizada por las personas o entidades a la cuales esta
dirigida. Si usted no es el destinatario autorizado, cualquier modificacion,
retension, difusion o copia total o parcial esta prohibida.
CONFIDENTIALITY NOTICE: This email and any files transmitted with it are
confidential and intended solely for the use of the individual or entity to
whom they are addressed. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail.
_______________________________________________
varnish-misc mailing list
[email protected]
http://lists.varnish-cache.org/mailman/listinfo/varnish-misc