Multiple instances of varnish

Mike Franon kongfranon at gmail.com
Fri May 13 23:35:51 CEST 2011


So I got the F5 to insert a custom header, and that works.

I also want to send everything that is a bot to a different backend,
and except for two urls,  and have it cache everything.


That works, except I realized I am missing one thing, unset cookies
from bots from the  different backend.

Currently I do not want to unset all cookies from all url's unless it
is a bot.  If it is a bot then yes unset all cookies, but the custom
header that the F5 inserts, when it comes back, is not there anymore.

Anyone have any ideas just curious.

Thanks


sub vcl_recv {

if (req.http.x-f5-bot-found){
   if (req.url ~ "^/some" || req.url ~ "^/sample"){
       set req.backend = bots_81;
       return(pass);
   }
   else {
       unset req.http.cookie;
       set req.backend = bots_81;
   }
}


if (req.url ~ "^/$" || req.url ~ "^/sale"){
                unset req.http.cookie;
                return(lookup);
}

else {
                return(pass);
}

}
sub vcl_fetch {
    if (req.url ~ "^/$" || req.url ~ "^/sale"){
        set beresp.ttl = 300s;
        set beresp.http.cache-control = "public, max-age = 300";
        set beresp.http.X-CacheReason = "varnishcache";
        unset beresp.http.set-cookie;
        return(deliver);
    }
}





On Fri, May 6, 2011 at 3:54 AM, Hettwer, Marian <mhettwer at team.mobile.de> wrote:
>
> On 05.05.11 19:00, "david raistrick" <drais at icantclick.org> wrote:
>
>>On Thu, 5 May 2011, Mike Franon wrote:
>>
>>> I am trying to see if there is a way with using a single instance
>>>
>>> 1)  Varnish using VCL to recognize that it is a bot
>>>
>>> 2)  If it is a bot request, varnish will then use a different backend.
>>
>>Sure.  You don't need multiple varnishes for this.
>>
>>Define your backend, create a rule that matches on the headers you're
>>matching on, set the backend.
>>
>>I don't have anything that matches on user agents (which is what I assume
>>you're looking at on the F5), and I'm not going to look at the docs to
>>find out how to match on them, but an example that does the same thing
>>for
>>URIs:
>
> If the F5 is able to recognize a bot, let it just insert a custom http
> header (X-F5-Found-Bot or something like that) and later match in vcl_recv
> on this header.
>
> Pretty much like this:
>
> sub vcl_recv {
>  if (req.http.X-F5-Found-Bot) {
>  set req.backend = backendforbots;
>        }
> }
>
>
>
> HTH,
> Marian
>
>




More information about the varnish-misc mailing list