Skip to content

Instantly share code, notes, and snippets.

@pepoviola
Last active April 27, 2018 16:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pepoviola/41b4cb1f0dca0fd4d489 to your computer and use it in GitHub Desktop.
Save pepoviola/41b4cb1f0dca0fd4d489 to your computer and use it in GitHub Desktop.
#
# based on: http://knowledgevoid.com/blog/2012/01/13/logging-the-correct-ip-address-using-apache-2-2-x-and-amazons-elastic-load-balancer/
# mod_evasive based on
# https://www.linode.com/docs/websites/apache-tips-and-tricks/modevasive-on-apache
# update cloudflare download link
# make sure you're root
sudo -i
wget https://raw.github.com/cloudflare/mod_cloudflare/master/mod_cloudflare.c
apt-get install apache2-prefork-dev # or apache2-threaded-dev
apxs2 -ci mod_cloudflare.c
tee /etc/apache2/mods-available/cloudflare.load <<EOF
LoadModule cloudflare_module /usr/lib/apache2/modules/mod_cloudflare.so
EOF
tee /etc/apache2/mods-available/cloudflare.conf <<EOF
CloudFlareRemoteIPHeader X-Forwarded-For
CloudFlareRemoteIPTrustedProxy 10.0.0.0/8
EOF
a2enmod cloudflare
service apache2 reload
# mod_evasive
apt-get install apache2-utils
cd /usr/src
wget http://www.zdziarski.com/blog/wp-content/uploads/2010/02/mod_evasive_1.10.1.tar.gz
tar xzf mod_evasive_1.10.1.tar.gz
cd mod_evasive
apxs2 -cia mod_evasive20.c
# add config
<IfModule mod_evasive20.c>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 60
DOSEmailNotify <someone@somewhere.com>
</IfModule>
/etc/init.d/apache2 restart
@shakaran
Copy link

shakaran commented Jul 1, 2016

Currently this script will not work since mod_evasive is under CloudFlare giving you a 503

wget http://www.zdziarski.com/blog/wp-content/uploads/2010/02/mod_evasive_1.10.1.tar.gz
--2016-07-01 21:54:12--  http://www.zdziarski.com/blog/wp-content/uploads/2010/02/mod_evasive_1.10.1.tar.gz
Resolving www.zdziarski.com (www.zdziarski.com)... 104.28.28.22, 104.28.29.22
Connecting to www.zdziarski.com (www.zdziarski.com)|104.28.28.22|:80... connected.
HTTP request sent, awaiting response... 503 Service Temporarily Unavailable
2016-07-01 21:54:12 ERROR 503: Service Temporarily Unavailable.

Do you know how to skip the 503 and avoid the manual download?

I try with this command but without luck:

wget --header="Cookie: __cfduid=xpzezr54v5qnaoet5v2dx1ias5xx8m4faj7d5mfg4og; cf_clearance=0n01f6dkcd31en6v4b234a6d1jhoaqgxa7lklwbj-1438079290-3600" -np -U "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0" --header="Accept: text/html" http://www.zdziarski.com/blog/wp-content/uploads/2010/02/mod_evasive_1.10.1.tar.gz -O - | tar -xvf

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