Varnish and hot linking

Chris Ferry chris at
Thu Jul 3 00:19:31 CEST 2008

I've set up varnish to handle hot linking, but I have an issue with  
varnish caching the "hotlink" image for the image request.

Here's the relevant part of default.vcl:

sub vcl_recv {

# Add a unique header containing the client address
remove req.http.X-Forwarded-For;
set    req.http.X-Forwarded-For = client.ip;
         if (req.request == "GET") {
                 if ( !(req.http.referer ~ "[a-z0-9]| 
yahoo.|||google.|search?q=cache" ) &&  
( ~ "^(raw)?images.domain.") && (req.http.referer) ) {
                     set req.url="";

         if (req.request == "PURGE") {
                 error 200 "OK!!";

The problem is this,  a user hotlinks 
  and we return hotlink.gif.
Now if a user legitimately loads puppy.jpeg he receives the cached  
copy of hotlink.gif in its place.
I though by setting the req.url that the cached file is now  
hotlink.gif and we haven't even attempted to store puppy.jpeg in the  
I need to legitimately serve puppy.jpeg even if it's being hotlinked  
from somewhere.
Any help would be appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list