Skip to content

Instantly share code, notes, and snippets.

@rolandinsh
Last active August 29, 2015 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolandinsh/52197d4d4feb37dffe9b to your computer and use it in GitHub Desktop.
Save rolandinsh/52197d4d4feb37dffe9b to your computer and use it in GitHub Desktop.
block spam referers in NGINX. Can be used as global block for all sites; (used on my production server(s))
# Block semalt.com buttons-for-website.com buttons-for-your-website.com best-seo-offer.com 100dollars-seo.com semaltmedia.com as referral spam
# (c) 2015 Rolands Umbrovskis, http://umbrovskis.com
# if code above do not work:
if ($http_referer ~ "(semaltmedia\.com|100dollars-seo\.com|semalt\.com|buttons-for-website.com|buttons-for-your-website\.com|best-seo-offer\.com)") {
set $prohibited "1";
}
if ($prohibited) {
return 403;
}
##
# Version 2
##
#if ($http_referer ~* "(semaltmedia\.com|100dollars-seo\.com|semalt\.com|buttons-for-website.com|buttons-for-your-website\.com|best-seo-offer\.com)"){
# return 403;
#}
@rolandinsh
Copy link
Author

@rolandinsh
Copy link
Author

see also: https://gist.github.com/rolandinsh/93cb9a5f08f52d7065b4 creating config file for nginx with .sh

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