Giter Site home page Giter Site logo

stevie-ray / referrer-spam-blocker Goto Github PK

View Code? Open in Web Editor NEW
373.0 52.0 87.0 2.71 MB

Apache, Nginx, IIS, uWSGI, Caddy & Varnish blacklist + Google Analytics segments to prevent referrer spam traffic 🤖

License: MIT License

PHP 4.54% VCL 95.46%
referrer-spam google-analytics spam-filtering referrer-spam-blocker spam-prevention

referrer-spam-blocker's Introduction

Referrer Spam Blocker 🤖

Apache, Nginx, IIS, uWSGI, Caddy & Varnish blacklist + Google Analytics segments to prevent referrer spam traffic


Latest Stable Version Build Status Libraries.io dependency status for latest release Code Quality Packagist License


Apache: .htaccess

.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

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;
	}
}

Varnish: .refferal-spam.vcl

Add referral-spam.vcl to Varnish 4 default file: default.vcl by adding the following code right underneath your default backend definitions

include "referral-spam.vcl";
sub vcl_recv { call block_referral_spam; }

IIS (Internet Information Services): web.config

The web.config file is located in the root directory of your Windows Server web application.

Caddy (HTTP/2 Web Server with Automatic HTTPS): referral-spam.caddy and referral-spam.caddy2

Move this file next to your Caddy config file, and include it by doing:

# For Caddy 1:
 include ./referral-spam.caddy;
# For Caddy 2:
 import ./referral-spam.caddy2

Then start your caddy server. All the referrers will now be redirected to a 444 HTTP answer

uWSGI: referral_spam.res

Include the file referral_spam.res into your vassal .ini configuration file:

ini = referral_spam.res:blacklist_spam

HAProxy: referral-spam.haproxy

Use it in your HAProxy config by adding all domains.txt items, in any frontend, listen or backend block:

acl spam_referer hdr_sub(referer) -i -f /etc/haproxy/referral-spam.haproxy
http-request deny if spam_referer

Options for Google Analytics 'ghost' spam

The above methods don't stop the Google Analytics ghost referral spam (because they are hitting Analytics directly and don't touching your website). You should use filters in Analytics to prevent ghost referral spam and hide spam form the past. Because Google Analytics segments are limited to 30.000 characters the exclude list is separated into multiple parts.

Navigate to your Google Analytics Admin panel and add these Segments:

Filter Session Include
Hostname matches regex ```your-website.com
Filter Session Exclude
Source matches regex Copy all the domains from google-exclude-1.txt to this field

Do the same for google-exclude-2.txt. Please note there may be more files in the future.

You can also prevent ghost referral spam by:

Intregrate in a Dockerfile

You can also integrate these configuration file in your Docker repo, so you will get always the most updated version when you build your image. For Apache, Nginx, Varnish 4 or IIS add the following line to your Dockerfile

# Apache: Download .htaccess to /usr/local/apache2/htdocs/
ADD https://raw.githubusercontent.com/Stevie-Ray/referrer-spam-blocker/master/.htaccess /usr/local/apache2/htdocs/

# Nginx: Download referral-spam.conf to /etc/nginx/
ADD https://raw.githubusercontent.com/Stevie-Ray/referrer-spam-blocker/master/referral-spam.conf /etc/nginx/

# Varnish 4: Download referral-spam.vcl to /etc/varnish/
ADD https://raw.githubusercontent.com/Stevie-Ray/referrer-spam-blocker/master/referral-spam.vcl /etc/varnish/

# IIS: Download web.config to /sitepath/ (change sitepath accordingly)
ADD https://raw.githubusercontent.com/Stevie-Ray/referrer-spam-blocker/master/web.config /sitepath/

# Caddy: Download referral-spam.caddy to /sitepath/ (next to your Caddy config file given through -conf)
ADD https://raw.githubusercontent.com/Stevie-Ray/referrer-spam-blocker/master/referral-spam.caddy /sitepath/

# uWSGI: Download referral_spam.res to /sitepath/ (change sitepath accordingly)
ADD https://raw.githubusercontent.com/Stevie-Ray/referrer-spam-blocker/master/referral_spam.res /sitepath/

Like it?

referrer-spam-blocker's People

Contributors

andrewgamez avatar brendanmullan avatar chrisloftus avatar daugsbi avatar delirius avatar gamesh avatar generitek avatar joshkoberstein avatar julianxhokaxhiu avatar mitchellkrogza avatar oddtwelve avatar paleite avatar peterjurkovic avatar pierstoval avatar sah62 avatar simbus82 avatar skmbr avatar stevie-ray avatar thiagotalma avatar whoacowboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

referrer-spam-blocker's Issues

New spam?

Hi,
social-widget.xyz
net-profits.xyz

are new spam?
B.

New spam ?

Hi all,
it seems that the below links are in someway spamming.....
vilingstore.net
znaniyapolza.ru
womensplay.net
den-noch24.ru
runstocks.com
lego4x4.ru
carsnumber.com
vpnhowto.info
runstocks.com
all4invest.ru

the above sites are mainly from Russia and don't have any relationship with the one I have up. I have a mean value of 10 hits/day from each one.
Thank you
B.

Spam

Hi,
new in town.....

sexsaoy.com
inzn.ru
voloomoney.com
zastenchivosti.net
zdesoboi.com
homelygarden.com

KR
B.

Spam domains

Another four to add to the list:

  • topquality.cf
  • easycommerce.cf
  • suche.t-online.de
  • marketland.ml

500 Error

Hi,

I'm trying to use your htaccess to block referral spam.
I have the following problem
If I add to my htaccess the below part of the code I get a 500 internal server error. The rest works fine
Can you help?

SetEnvIfNoCase Referer 4webmasters.org spambot=yes
SetEnvIfNoCase Referer 7makemoneyonline.com spambot=yes
SetEnvIfNoCase Referer acunetix-referrer.com spambot=yes
SetEnvIfNoCase Referer adcash.com spambot=yes
SetEnvIfNoCase Referer advokateg.com spambot=yes
SetEnvIfNoCase Referer advokateg.ru spambot=yes
SetEnvIfNoCase Referer baixar-musicas-gratis.com spambot=yes
SetEnvIfNoCase Referer best-seo-offer.com spambot=yes
SetEnvIfNoCase Referer best-seo-solution.com spambot=yes
SetEnvIfNoCase Referer bestwebsitesawards.com spambot=yes
SetEnvIfNoCase Referer blackhatworth.com spambot=yes
SetEnvIfNoCase Referer buttons-for-website.com spambot=yes
SetEnvIfNoCase Referer buttons-for-your-website.com spambot=yes
SetEnvIfNoCase Referer buy-cheap-online.info spambot=yes
SetEnvIfNoCase Referer cenokos.ru spambot=yes
SetEnvIfNoCase Referer cenoval.ru spambot=yes
SetEnvIfNoCase Referer cityadspix.com spambot=yes
SetEnvIfNoCase Referer darodar.com spambot=yes
SetEnvIfNoCase Referer descargar-musicas-gratis.com spambot=yes
SetEnvIfNoCase Referer econom.co spambot=yes
SetEnvIfNoCase Referer edakgfvwql.ru spambot=yes
SetEnvIfNoCase Referer event-tracking.com spambot=yes
SetEnvIfNoCase Referer fbdownloader.com spambot=yes
SetEnvIfNoCase Referer forum20.smailik.org spambot=yes
SetEnvIfNoCase Referer free-share-buttons.com spambot=yes
SetEnvIfNoCase Referer free-social-buttons.com spambot=yes
SetEnvIfNoCase Referer googlsucks.com spambot=yes
SetEnvIfNoCase Referer gobongo.info spambot=yes
SetEnvIfNoCase Referer guardlink.org spambot=yes
SetEnvIfNoCase Referer hulfingtonpost.com spambot=yes
SetEnvIfNoCase Referer humanorightswatch.org spambot=yes
SetEnvIfNoCase Referer iedit.ilovevitaly.com spambot=yes
SetEnvIfNoCase Referer ilovevitaly.com spambot=yes
SetEnvIfNoCase Referer ilovevitaly.co spambot=yes
SetEnvIfNoCase Referer ilovevitaly.info spambot=yes
SetEnvIfNoCase Referer ilovevitaly.org spambot=yes
SetEnvIfNoCase Referer ilovevitaly.ru spambot=yes
SetEnvIfNoCase Referer iskalko.ru spambot=yes
SetEnvIfNoCase Referer lomb.co spambot=yes
SetEnvIfNoCase Referer luxup.ru spambot=yes
SetEnvIfNoCase Referer make-money-online.7makemoneyonline.com spambot=yes
SetEnvIfNoCase Referer maps.ilovevitaly.com spambot=yes
SetEnvIfNoCase Referer myftpupload.com spambot=yes
SetEnvIfNoCase Referer net.hts.ru spambot=yes
SetEnvIfNoCase Referer offers.bycontext.com spambot=yes
SetEnvIfNoCase Referer o-o-6-o-o.ru spambot=yes
SetEnvIfNoCase Referer o-o-6-o-o.com spambot=yes
SetEnvIfNoCase Referer o-o-8-o-o.ru spambot=yes
SetEnvIfNoCase Referer priceg.com spambot=yes
SetEnvIfNoCase Referer resellerclub.com spambot=yes
SetEnvIfNoCase Referer responsinator.com spambot=yes
SetEnvIfNoCase Referer ?????.?? spambot=yes
SetEnvIfNoCase Referer savetubevideo.com spambot=yes
SetEnvIfNoCase Referer screentoolkit.com spambot=yes
SetEnvIfNoCase Referer semalt.com spambot=yes
SetEnvIfNoCase Referer seoexperimenty.ru spambot=yes
SetEnvIfNoCase Referer shopping.ilovevitaly.ru spambot=yes
SetEnvIfNoCase Referer simple-share-buttons.com spambot=yes
SetEnvIfNoCase Referer slftsdybbg.ru spambot=yes
SetEnvIfNoCase Referer socialseet.ru spambot=yes
SetEnvIfNoCase Referer social-buttons.com spambot=yes
SetEnvIfNoCase Referer srecorder.com spambot=yes
SetEnvIfNoCase Referer st3.cwl.yahoo.com spambot=yes
SetEnvIfNoCase Referer superiends.org spambot=yes
SetEnvIfNoCase Referer theguardlan.com spambot=yes
SetEnvIfNoCase Referer vodkoved.ru spambot=yes
SetEnvIfNoCase Referer websocial.me spambot=yes
SetEnvIfNoCase Referer www1.social-buttons.com spambot=yes
SetEnvIfNoCase Referer www.Get-Free-Traffic-Now.com spambot=yes
SetEnvIfNoCase Referer ykecwqlixx.ru spambot=yes
SetEnvIfNoCase Referer yougetsignal.com spambot=yes

New spam

I suppose it is new spam

get-your-social-buttons.info

Spam

Another one for the list:

  • getlamborghini.ga

New spam

Just had this one appear in Google Analytics:

  • getrichquick.ml

New

kw21.org

zahvat.ru
betonka.pro
videochat.mx
regionshop.biz
wedding-salon.net
video-chat.in
td-33.ru
mylida.org
alveris.ru
xn----7sbaphztdjeboffeiof6c.xn--p1ai
obuv-kupit.ru
ustion.ru
mmog-play.ru
firma-legion.ru
remontgruzovik.ru

itbc.kiev.ua
djonwatch.ru
biznesschat.net

New referral spam

rankings-analytics.com
siteevaluation.com s
mir-betting
salutmonreal.com
xn----7sbho2agebbhlivy.xn--p1ai
burger-impria.com
clicksor

Why Fiverr?

I had a potential client from Fiverr visiting my website and getting blocked thanks to your config 👎

Expected Behavior

It should not be blocking referrs from fiverr.com

Current Behavior

It blocks visitors from fiverr.com

Possible Solution

Offending line: should be removed:

` "~*fiverr.com" 1;

Steps to Reproduce (for bugs)

Send link to your website where this configuration is enabled from within Fiverr.com private conversation.

New spam?

Hi all,
this is hitting my e-commerce site
site8441136.snip.tw

it is spam?

Syntax error

Great job!

Is experiencing an error with the domain that uses special characters.

Syntax error on line 111 of /etc/apache2/httpd.conf:
RewriteCond: cannot compile regular expression '^http(s)?://(www\\.)?r????.??\\.*$'
Action 'configtest' failed.
The Apache error log may have more information.

I suggest removing this domain
https://github.com/Stevie-Ray/htaccess-referral-spam-blacklist-block/blob/master/.htaccess#L87

You can validate the file here: http://www.lyxx.com/freestuff/002.html

env=spambot and RewriteRule missing?

It seems env=spambot is not set and the deny rules do nothing? There are jut the rewrite condtitions but no rewrite rule which sets the variable.

New spam

velobikestock.com
video-chat.in
betonka.pro

New spam

Seeing referrals from:

  • forum.topic68146219.6hopping.com

A quick Google suggests the number (topic) varies.

Apache 2.4 compatibility

Dear developers,
my question is about the upgrade from Apache 2.2 to Apache 2.4.
The code:

<IfModule mod_setenvif.c>
    SetEnvIfNoCase Referer yougetsignal.com spambot=yes
    ....

    Order allow,deny
    Allow from all
    Deny from env=spambo
</IfModule>

cause an error in apache2ctl configtest:

AH00526: Syntax error on line XXX of /etc/apache2/sites-enabled/XXXX.conf:
Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.

According to the official page, the directives must be updated.
http://httpd.apache.org/docs/2.4/upgrading.html

How can I adapt the directive to Apache 2.4 sintax?

Spam

New

https-legalrc.biz
ordernorxx.com
biznesluxe.ru
mrwhite.biz
linerdrilling.com
fix-website-errors.com
finteks.ru
styro.ru
woman-orgasm.ru
iqoption-bin.com
flooringinstallation-edmonton.com
ideibiznesa2015.ru
pravoholding.ru
vashsvet.com
shopvilleroyboch.com.ua
mmog-play.ru
vgoloveboli.net
kupit-adenu.ru
pravoholding.ru
linerdrilling.com
pron.pro
shopvilleroyboch.com.ua
dnepr-avtospar.com.ua
saitevpatorii.com
vesnatehno.ru
alveris.ru
wedding-salon.net
wallpapersdesk.info
letolove.ru
muz-baza.net
positive2b.ru
zajm-pod-zalog-nedvizhimosti.ru
djonwatch.ru
hd720kino.ru
kinobaks.com
itbc.kiev.ua
remontgruzovik.ru
xn--80aaajbdbddwj2alwjieei2afr3v.xn--p1ai
abiente.ru
xboxster.ru
most-kerch.org
videochat.mx
rumamba.com
kw21.org

New spam?

top1-seo-service.com/try.php

from semalt

Add

success-seo.com
videos-for-your-business.com
fcp.intermesh.net
pizza-tycoon.com
blackle.com
jwss.cc
nate.com
traffic2money.com

Spam report

Hi all,
it seems that from Russia in the recent days are making party spam .... ;)
I had new hits from
istock-mebel.ru
ifirestarter.ru
avtocredit-legko.ru
woman-h.ru
forum.tvmir.org
foxinsocks.ru
vykup-avto-krasnodar.ru
creditmoney.com.ua
fm-upgrade.ru
money-every-day.com
runovschool.ua
gsmtlf.ru
KR
Boris

Spam

Hi,

azlex.uz
pozdrawleniya.ru
pornophoto.xyz
zdesoboi.com
sad-torg.com.ua
office-windows.ru
vykupavto-krasnodar.ru

New spam

Few more for the list:

  • burn-fat.ga
  • magicdiet.gq
  • ghostvisitor.com
  • massage-info.nl
  • eu-cookie-law-enforcement-6.xyz

New Spam

I have these domains in GA list:

share-buttons.xyz
traffic2cash.xyz
с.новым.годом.рф
website-stealer-warning.hdmoviecamera.net
website-stealer.nufaq.com
build-a-better-business.2your.site
topseoservices.co

Are they spam ? Ublock block me to visit all these sites.

New spam ?

Hi I found many hits from
keywords-monitoring-your-success.com
can be the case to add it? I suppose a crawl spam type
KR
Boris

New ones spam

porodasobak.net
replicaclub.ru
dimkino.ru
flooringinstallation-edmonton.com
sad-torg.com.ua
pornoklad.net
e-collantes.com
keywords-monitoring-success.com
zvetki.ru
solitaire-game.ru
woman-orgasm.ru
euronis-free.com
sygraem.com
zaim-pod-zalog-krasnodar.ru
vesnatehno.com
iqoption-bin.com
pornoblood.com
ideibiznesa2015.ru
fix-website-errors.com
biznesluxe.ru

fatal error in apache htaccess

It seems like the regular expression of video-production.com ist wrong. I have resolved this issue on my server by removing this line, but perhaps you like to fix it in your own code.

This is from my apache-log:

[Mon Aug 17 11:26:05 2015] [alert] [client xx.xx.xx.xx] /var/www/vhosts/....../httpdocs/.htaccess: RewriteCond: cannot compile regular expression '^http(s)?://(www.)?.video--\production.com.$'

I think it should be like this (look at backslashes):
^http(s)?://(www.)?._video\-\-production.com._$

new entry here

Hello!
Thanks a lot for sharing this.
I have just added a new entry noticed in my GA:
copyrightclaims.org

OR condition

I am not a mod_rewrite specialist, but is it normal that the zverokruh line does not contain an OR condition?

RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?._zazagames.org._$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www.)?._zverokruh-shop.cz._$ [NC]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www1?.)?.social-buttons.com.$ [NC,OR]

Syntax error

Hi!
They are a syntax error in line 94:
"
_burger-imperia.com
must be
"~_burger-imperia.com" 1;

Internal Server Error

I copied the regex spam rewrites from your .htaccess file to mine hosted on my Apache server, replacing the far more limited list I had already in my .htaccess file. However, now I get an internal server error when I upload the updated .htaccess file to my server. When I remove the added spam rewrites, I can access again.

Server error says: "The server encountered an internal error or misconfiguration and was unable to complete your request" Any ideas?

500 error

Hi, Just tried the latest version (180+) and received a 500 error
Anything I should be looking for?

sorry

Spam

videochat.tv.br
mylida.org
video-chat.in
laudit.ru
buy-cheap-pills-order-online.com
biznesschat.net

about the generator

currently generator works only on windows, i can't make it work on other OSes.

But i could write a php script that would work on all OSes, windows, mac, linux, but you would have to have a php installed to run it.
Or we could set up a travis CI to run the php script on incoming change that would generate those files zip them and put them into release.

Add Date / Version Information

It might be nice to include the latest date or a version number as a comment at the top of the lists. It will make keeping track of updates/changes quite a bit easier when updating the list on multiple hosts.

I.E. # Updated 2015-10-05

Thoughts?

New kind of referral spam

Hello everyone!
Today I noticed a new kind of referral spam in my Google Analytics account. It uses the parameter Landing Screen and provides a spammer's URL in it.
Has anyone else already encountered this?

P.S. I hope, I use the correct function to share my message. I am new to github, so please let me know, if creating an issue was wrong.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.