1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Banning most free proxies with htaccess or with a software?

Discussion in 'Blogging' started by Husbarn, Sep 18, 2014.

  1. Husbarn

    Husbarn Junior Member

    Joined:
    Dec 19, 2012
    Messages:
    160
    Likes Received:
    20
    What do you think is better?

    Does adding thousands of ips to a htaccess file adds a big "weight" on your resources?
     
  2. Sgt Kraut

    Sgt Kraut Regular Member

    Joined:
    Jun 22, 2012
    Messages:
    318
    Likes Received:
    287
    Blocking thousands of IPs with htaccess will have a negative impact on your site's loading speed. Better consider blocking some HTTP protocols proxies use with htaccess like the guy describes here: http://perishablepress.com/block-tough-proxies/.
     
    • Thanks Thanks x 2
  3. Masterptc

    Masterptc Regular Member

    Joined:
    Aug 9, 2011
    Messages:
    413
    Likes Received:
    600
    Home Page:
    I use some PHP code very similar to whats shared on link above ^ . Does good job blocking free proxy sites.
     
    • Thanks Thanks x 1
  4. djelica

    djelica Junior Member

    Joined:
    Jun 26, 2009
    Messages:
    151
    Likes Received:
    60
    Use MaxMind's free/paid GeoIP and php, you can achieve this very easy without adding thousands ips to htaccess which would be out of mind.

    And use php + mysql for banning single ips that you don't like. I can write the script for you quickly if you need it.
     
    • Thanks Thanks x 1
  5. Husbarn

    Husbarn Junior Member

    Joined:
    Dec 19, 2012
    Messages:
    160
    Likes Received:
    20
    The first option mentioned out there is not very smart in some ways (it was even mentioned in the comments out there), but the second option (.htaccess) looks good.

    So if I add this code to my .htaccess file:

    Code:
    <ifModule mod_rewrite.c>
     RewriteEngine on
     RewriteCond %{HTTP:VIA}                 !^$ [OR]
     RewriteCond %{HTTP:FORWARDED}           !^$ [OR]
     RewriteCond %{HTTP:USERAGENT_VIA}       !^$ [OR]
     RewriteCond %{HTTP:X_FORWARDED_FOR}     !^$ [OR]
     RewriteCond %{HTTP:PROXY_CONNECTION}    !^$ [OR]
     RewriteCond %{HTTP:XPROXY_CONNECTION}   !^$ [OR]
     RewriteCond %{HTTP:HTTP_PC_REMOTE_ADDR} !^$ [OR]
     RewriteCond %{HTTP:HTTP_CLIENT_IP}      !^$
     RewriteRule .* - [F]
    </ifModule>
    It will block free proxies? Can it cause some problems with real visitors (without proxies) and block them too?
     
  6. djelica

    djelica Junior Member

    Joined:
    Jun 26, 2009
    Messages:
    151
    Likes Received:
    60
    I think that would work for some %.
    Anyway I'd go with code and GeoIP and block Anonymous Proxy country and avoid .htaccess when ever possible because code gives you more control and navigating folder level deeper still causes httpd to look at the parent folder for .htaccess file contents. Meaning if you visit /rootfolder/subfolder/ apache will query httaccess in both /rootfolder/ and /rootfolder/subfolder/ as Sgt Kraut mentioned, performance matters.

    Depending on complexity of your case, maybe applying this htaccess trick will be just enough.

    I'd also suggest to redirect the traffic somewhere instead of showing a forbidden page.

    Best wishes.
     
    • Thanks Thanks x 1
  7. Husbarn

    Husbarn Junior Member

    Joined:
    Dec 19, 2012
    Messages:
    160
    Likes Received:
    20
    Just tried that htaccess method and it's poor. Only blocks the weakest proxies.

    PHP method given out there is no good too, because it can block a lot of real visitors without proxies.

    I need a method which could block elite and high anonymous proxies.
     
  8. martyrz

    martyrz Newbie

    Joined:
    Sep 14, 2013
    Messages:
    21
    Likes Received:
    1
    Location:
    Turkey
    CloudFlare maybe?
     
  9. jefftech

    jefftech Newbie

    Joined:
    Jun 28, 2015
    Messages:
    2
    Likes Received:
    0
    There is a really good php script that auto loads problem ip's, bots and proxies in your .htaccess file found here: myip.ms
     
  10. Redsox218

    Redsox218 Newbie

    Joined:
    Jul 15, 2010
    Messages:
    14
    Likes Received:
    0
    There are plugins out there ie. Spider Spanker that can accomplish this too