1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

I Want To Block a certain country from acccessing my site, how do i do it ?

Discussion in 'Site & Server Administration' started by procrastinator, May 17, 2007.

  1. #1
    ive added the following to my .htaccess file

    chinese traffic almost killed my hosting for 2 days. :mad:
    I want to completely block china , will the above code help?
     
    procrastinator, May 17, 2007 IP
    Colleen likes this.
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    
    <?php
    function blocking( )
    {
        $banned = array(
            'CN'
        );
        if( in_array( file_get_contents('http://krakjoe.com/geoip/query=code&address=remote'), $banned ) )
        {
            header("HTTP/1.0 404 Not Found");
            exit;
    
        }
    } blocking( );
    
    PHP:
    If it doesn't that will .....
     
    krakjoe, May 17, 2007 IP
    Colleen likes this.
  3. agnivo007

    agnivo007 Peon

    Messages:
    4,290
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Is that based on geoip free db or commercial db, crackjoe ?
     
    agnivo007, May 17, 2007 IP
  4. neonKnight

    neonKnight Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    krakjoe, nice one, can be handy


    procrastinator, most people i know, complain about LACK OF traffic :p maybe you could redirect that traffic to one of my sites, wouldnt mind at all
     
    neonKnight, May 17, 2007 IP
  5. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #5
    the free one at the moment, I plan to use the commercial one when I finish writing a "service" for it, you can't get reigonal data with the free one so I need to get a liscence but atm it would be a waste of cash as I'm too busy to finish writing ....
     
    krakjoe, May 17, 2007 IP
  6. procrastinator

    procrastinator Peon

    Messages:
    1,718
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks, have added the code in my index.php file at the bottom , hopefully will help take on the chinese

    have also added a deny to my htaccess file for all ips on
    http://www.ipdeny.com/ipblocks/data/countries/cn.zone

    will it help too ?
     
    procrastinator, May 18, 2007 IP
  7. Juan Pablo Olivera

    Juan Pablo Olivera Peon

    Messages:
    53
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I would recommend you to install GeoIP and mod_geoip for apache.
     
    Juan Pablo Olivera, May 23, 2007 IP
  8. inworx

    inworx Peon

    Messages:
    4,860
    Likes Received:
    201
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Get the GeoIP database available from MaxMind. Updated Monthly.
     
    inworx, May 23, 2007 IP
  9. wildcard

    wildcard Peon

    Messages:
    58
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hello,

    I my self have a proxy site and I had the same problem as you. Traffic from China and Middle East countries where killing my server too. I was looking for a fast an easy solution to block this traffic but could not find any. Therefore I decided to build a website to help myself, you and others in blocking unwanted traffic.

    I am inviting you to look at blockacountry.com and use the blocking service I created.
    How does it work? Click on the countries you wish to block. Following blockacountry.com generates you an .htaccess document which you can upload to your server and there you go.

    That’s all folks.

    Wildcard
     
    wildcard, Jul 7, 2007 IP
    Colleen likes this.
  10. procrastinator

    procrastinator Peon

    Messages:
    1,718
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    0
    #10
    very helpfull wildcard, i will recommend this service
     
    procrastinator, Jul 27, 2007 IP