Skip to content

Instantly share code, notes, and snippets.

@stephenyeargin
Last active August 31, 2018 13:41
Show Gist options
  • Save stephenyeargin/7688830fe97f9227418e to your computer and use it in GitHub Desktop.
Save stephenyeargin/7688830fe97f9227418e to your computer and use it in GitHub Desktop.
NGINX referral spam blocking

Following this guide + data from this page

File: /etc/nginx/global/referer-spam.conf

##
# Referrer exclusions
##
if ($http_referer ~ "(buttons-for-website\.com|darodar\.com|econom\.co|ilovevitaly\.co|kambasoft\.com|lumb\.co|7makemoneyonline\.com|ranksonic\.info|savetubevideo\.info|see-your-website-here\.com|semalt\.com|priceg\.com|srecorder\.com|descargar-musica-gratis\.net|54\.186\.60\.77|lomb\.co)") {
  set $prohibited "1";
}
if ($http_referer ~ "(medispainstitute|sq01|alienpayday|artobox|axisalternativementalhealthsharebutton\.net|torontoplumbinggroup\.com|tasteidea\.com|paparazzistudios\.com\.au|76brighton\.co\.uk|powitania\.pl|ilovevitaly\.ru|ilovevitaly\.com|blackhatworth\.com|hulfingtonpost\.com)") {
  set $prohibited "1";
}
if ($http_referer ~ "(cenoval\.ru|bestwebsitesawards\.com)") {
  set $prohibited "1";
}

if ($prohibited) {
  return 403;
}

File: /etc/nginx/sites-available/yoursite.conf

server {
[...]
  passenger_app_env production;

  include /etc/nginx/global/*;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment