Search code examples
nginxreferrer-spam

How to block referral spam using Nginx?


I'm running two mongrels under an Nginx server. I keep getting requests for a nonexistent file. The IP addresses change frequently but the referring URL stays the same. I'd like to resolve this.


Solution

  • https://calomel.org/nginx.html

    Block most "referrer spam" -- "more of an annoyance than a problem"

    nginx.conf

        ## Deny certain Referers (case insensitive)
        ## The ~* makes it case insensitive as opposed to just a ~
     if ($http_referer ~* (babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|video|webcam|zippo))
        {  return 403;   }