client.identity and client director -- How?

Michael Bu michael.bu at gmail.com
Wed Dec 1 20:48:04 CET 2010


Thanks for your reply.

I could of course hard-coded the intended behavior with an "if" clause.

But it would be nice to take advantage of the new "Client Director" feature
which unfortunately wasn't documented...

Thanks,
Michael

On Thu, Dec 2, 2010 at 3:23 AM, Caunter, Stefan <scaunter at topscms.com>wrote:

>  Use an if in vcl_recv. If you need to stick based on cookie, use that
> header; I use X-F-F for a load-balancer setup.
>
>
>
> sub vcl_recv {
>
> # set client.identity based on x-f-f header, use that to stick to a backend
> server
>
>
>
>                 if (req.http.x-forwarded-for) {
>
>                         set client.identity = req.http.x-forwarded-for;
>
>                         set req.backend = tomcat;
>
>                 }
>
>                 # more stuff goes here
>
>                 return(lookup);
>
> }
>
>
>
> Stefan Caunter :: Senior Systems Administrator :: TOPS
>
> e: scaunter at topscms.com  ::  m: (416) 561-4871
>
> www.thestar.com www.topscms.com
>
>
>
> *From:* varnish-misc-bounces at varnish-cache.org [mailto:
> varnish-misc-bounces at varnish-cache.org] *On Behalf Of *Michael Bu
> *Sent:* December-01-10 2:16 PM
> *To:* varnish-misc at varnish-cache.org
> *Subject:* client.identity and client director -- How?
>
>
>
> Hi All,
>
>
> I want to know how to setup a client director and make use of
> client.identity to force the request always going to the same backend
> instance (ie. sticky).
>
> Here's my setup:
>
> backend a {
>   .host = "192.168.1.4";
>   .port = "8880";
> }
> backend b {
>   .host = "192.168.1.5";
>   .port = "8880";
> }
> director tomcat client {
>     {
>         .backend = a;
>         .weight = 1;
>     }
>     {
>         .backend = b;
>         .weight = 1;
>     }
> }
> sub vcl_recv {
>     ## set sticky bit for backend director ##
>     set client.identity = regsub(req.http.Cookie,
> ".*JSESSIONID=.*\.(\w).*", "\1");
>     set req.backend = tomcat;
> }
>
> Unfortunately the above setup didn't work as expected.
>
> Could some one please give me some advice?
>
> Thanks in advance!
> Michael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20101202/7740643b/attachment-0003.html>


More information about the varnish-misc mailing list