Nginx: How To Stop Referrer Spam With Keyword Filtering

By Angsuman Chakraborty, Gaea News Network
Friday, August 8, 2008

You can configure Nginx to stop referrer spam by checking for bad keywords like tramadol, phentermine etc. This reduces the load on your server as well as prevents filling your referrer logs with invalid entries. Here is my nginx configuration to stop referrer spam (feel free to copy it):

# 403 forbidden based on http referer
if ($http_referer ~* "tramadol|viagra|levitra|adipex|virex|antispysoft2005\.com|mydivx\.info|my-pills\.be|cameralover\.net|credit-dreams\.com|the-discount-store\.com|bayfronthomes\.net|casino|poker|hackerssupply\.com|hydrocodone|cafexml\.com|yelucie\.com|crescentarian\.net|andrewsaluk\.com|tigerspice|doobu\.com|camfun24|latinonakedgirl|ronnieazza\.com|highprofitclub|dvdsqueeze\.com|sexsearchcom\.com|6q\.org|d4f\.de|adultactioncam|seventwentyfour\.com|genaholincorporated\.com|firsthorizonmtg\.com|personalsites\.info|bukakke-bukake-bukkake-bukkakke\.com|camgirlslive\.com|dvd-copy\.com|shaffelrecords\.com|mcr8\.com|dating\.blogs\.com|online-casino-pops|8thstreetlatinas|boysfirsttime\.com|gofordgo\.com|chile-online\.com|buy-hgh-human-growth-hormone\.net") {
    return 403;
}
Discussion
September 13, 2008: 9:46 am

[...] Nginx: How To Stop Referrer Spam With Keyword Filtering [...]

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :