Skip to content

Instantly share code, notes, and snippets.

@pepoviola
Last active April 27, 2018 16:16
Show Gist options
  • Select an option

  • Save pepoviola/41b4cb1f0dca0fd4d489 to your computer and use it in GitHub Desktop.

Select an option

Save pepoviola/41b4cb1f0dca0fd4d489 to your computer and use it in GitHub Desktop.

Revisions

  1. pepoviola revised this gist Aug 25, 2014. 1 changed file with 26 additions and 1 deletion.
    27 changes: 26 additions & 1 deletion install_mod_cloudflare and mod_evasive
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    #
    # 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
    @@ -15,4 +19,25 @@ CloudFlareRemoteIPHeader X-Forwarded-For
    CloudFlareRemoteIPTrustedProxy 10.0.0.0/8
    EOF
    a2enmod cloudflare
    service apache2 reload
    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 <[email protected]>
    </IfModule>

    /etc/init.d/apache2 restart
  2. pepoviola renamed this gist Aug 25, 2014. 1 changed file with 0 additions and 0 deletions.
  3. pepoviola created this gist Aug 25, 2014.
    18 changes: 18 additions & 0 deletions install_mod_cloudflare
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #
    # based on: http://knowledgevoid.com/blog/2012/01/13/logging-the-correct-ip-address-using-apache-2-2-x-and-amazons-elastic-load-balancer/
    # 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