We are checking for a couple of spammy referrers in our nginx configuration and want to redirect their requests to our homepage. The problem is that nginx is passing along the original referer as part of the redirect, and so when the redirected request comes in, the bad referer is still present and nginx issues another redirect. Example:
Bad site links to example.com/page.html
. We redirect that request to example.com
because we don't want the bad referers to send traffic to our pages. The problem is that when nginx receives the request for example.com
, that bad referer is still present and so nginx issues another redirect, and so on to infinity. How can I clear the original referer when issuing a redirect from nginx?
Here is the relevant block that we're using. We populate $bad_referer
with a map
in the http section of our config.
if ($bad_referer) {
return 302 http://www.example.com;
}
return 301
) fix the problem?