Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiNaPsEr0x/9fd9484473d7b2f91ebbe62bcaf12ed2 to your computer and use it in GitHub Desktop.
Save SiNaPsEr0x/9fd9484473d7b2f91ebbe62bcaf12ed2 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment