Spam referrals cluttering analytics is frustrating. Here’s a VCL 4.0 approach to redirect suspicious referral sources.

Implementation

The solution uses a custom subroutine to identify and redirect problematic referrers:

sub bad_referrals {
     if ( req.http.referer ~ "hulfingtonpost" ||
          req.http.referer ~ "forum.topic57969834.darodar" ||
          req.http.referer ~ "ilovevitaly" ||
          req.http.referer ~ "priceg" ||
          req.http.referer ~ "blackhatworth.com"
     ) {
          set req.http.host = "www.ihateyousomuchomgroflcats.com";
          return(synth(750, "All your referer are belong to us."));
     }
}

The configuration integrates into the receive and synthesis subroutines, ultimately directing flagged traffic via HTTP 301 redirect to an alternative destination.

Administrators can customize the referrer matching patterns and redirect targets according to their specific needs, effectively removing spam referral sources from analytics reporting.