Banning objects by req.url and Authorization header.

Kim Eik kim at heldig.org
Wed Mar 28 20:01:30 CEST 2012


Hi, i'm fairly new to varnish. And i'm trying to get this configuration to work.


sub vcl_recv {
  if(req.request == "PUT" && req.url ~ "^/api/0.1/userMedia"){
    ban ("req.url == /api/0.1/user && req.http.Authorization == " +
req.http.Authorization);
    return(pass);
  }
  if(req.url ~ "^/api/0.1"){
    return(lookup);
  }
}

sub vcl_hash {
  if(req.url ~ "^/api/0.1"){
    hash_data(req.http.Authorization);
  }
}

Basically what i'm trying to do is in the case where there is a
request against /api/0.1/userMedia with the request method PUT, then i
want to evict any cached objects which matches the url /api/0.1/user
and that has the same Authorization header.

Everything worked fine until i added  && req.http.Authorization == " +
req.http.Authorization to the ban line. What is the proper way to do
this?

Any help on this is appreciated.
-Kim



More information about the varnish-misc mailing list