Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.