Skip to content

Apache and Nginx files to prevent referral spam traffic on a server level.

Notifications You must be signed in to change notification settings

skmbr/apache-nginx-referral-spam-blacklist

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

apache-nginx-referral-spam-blacklist

These files are created to collect and prevent referral spam traffic sources on a server level.


Apache: .htaccess usage

.htaccess is a configuration file for use on web servers running Apache. This file is usually found in the root “public_html” folder of your website. The .htaccess file uses two modules to prevent referral spam, mod_rewrite and mod_setenvif. Decide which method is most suitable with your Apache server configuration. This file is Apache 2.4 ready, where mod_authz_host got deprecated.

Nginx: referral-spam.conf usage

With referral-spam.conf in /etc/nginx, include it globally from within /etc/nginx/nginx.conf:

http {
	include referral-spam.conf;
}

Add the following to each /etc/nginx/site-available/your-site.conf that needs protection:

server {
	if ($bad_referer) {
		return 444;
	}
}

Options for Google Analytics 'ghost' spam

NOTE: This method doesn't stop the Google Analytics 'ghost' referral spam (because they are hitting Analytics directly and not even touching your website / server). You should also use filters in Analytics to prevent referral spam.

You can prevent referral spam by:

Use the link above or go to your Google Analytics Admin panel and add a Segment.

screen shot 2015-07-27 at 20 50 08

Filter Session Include
Hostname matches regex ```your-website.com
Filter Session Exclude
Source matches regex ```semalt.com

and so on..

Downloading

If you want to download both files, see the latest zip. Otherwise, if you need to make changes to these files, clone the repo with:

git clone --recursive https://github.com/Stevie-Ray/apache-nginx-referral-spam-blacklist-block.git

Contributing

If you'd like to help, contribute feedback, or just fork the repository, then add useful stuff and send a pull request.

About

Apache and Nginx files to prevent referral spam traffic on a server level.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • ApacheConf 100.0%