Blocking China and India

My website has been getting a fair amount of visitors from China.

That spells trouble to me.

How do I block visitors from China and India?

Thanks,

Debbie

DD,

The ip2country websites have lists of IP addresses from all countries. Download their database (or use a look-up tool to log-in) and get those IP address blocks and DENY each block. Unfortunately, you’ll find that there are a huge list of blocks (for each) and really should block in the server’s conf (or your vhosts.conf) file.

Regards,

DK

You can use a geo-targeting script.

Using the script, you can choose to redirect China and India visitors to some other sites like Google.

Do I have to pay to do that?

Unfortunately, you’ll find that there are a huge list of blocks (for each)

How reliably can I say, “Block everyone coming from China”??

and really should block in the server’s conf (or your vhosts.conf) file.

Regards,

DK

I have a VPS, so how would I do that?

Debbie

Can you elaborate some more?

I’m not following you.

Debbie

DD,

What does <directory> do?

What is FollowSymLinks used for?

What is AllowOverride used for?

I don’t understand your code above.

The way I have seen it online, you do…


Order Allow,Deny
Deny From_____
Allow From All

It seems like your code doesn’t account for Allowing IP’s that are not on the Deny list?!

Debbie

DD,

I did a search for “block Chinese traffic” and received several great links:

http://www.countryipblocks.net/country-blocks/select-formats/ will provide the list of IP blocks by country in selectable formats.

http://www.maxmind.com/app/mod_geoip provides an Apache module which you can install for a quick lookup on your server - directions are on the site.

http://www.parkansky.com/china.htm gives the exact code for China, Russia, etc. by blocking IP address ranges.

All these are TOO MUCH for an .htaccess file so be sure to only test there briefly before moving to your Apache2.conf file on the production server.

One clue, though, since you only want US visitors. Reverse the Allow,Deny and list the US IP addresses in the Allow group and it will save you from my being able to view your website (from NZ), too!

Regards,

DK

Why?

Why would your code work okay in the Apache2.conf file but not in a .htaccess file?

Again, I don’t understand the difference is the approach.

One clue, though, since you only want US visitors. Reverse the Allow,Deny and list the US IP addresses in the Allow group and it will save you from my being able to view your website (from NZ), too!

Regards,

DK

For now I am okay with most countries, just not China, India, Russia, and a few others plus a few renegade IP’s in NZ… :wink:

Can we go over this again…


<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from {list of IP address blocks}
 </Directory>

1.) Am I supposed to replace “<Directory />” with something specific like “Path to Debbie’s Web Root”??

2.) If I leave out…


Options FollowSymLinks
    AllowOverride All

…what would happen?

3.) This code…

    Order deny,allow

…says, "Perform Deny directives first and then do Allow directives next, right?

4.) If there are no allowable IP’s in #3, then isn’t that a problem?

I thought we want to say “Deny these IP’s and then Allow everything else that is remaining”?

5.) Does just the order of this line matter…


    Order deny,allow

Or does the order of the following lines matter to…


Deny from all
Allow from example.com

Thanks,

Debbie

DD,

Regards,

DK

Well, I didn’t know that. That is why I was asking!

That makes total sense.

Sounds like using .htaccess is evil…

Well, that makes it harder to implement (more lines of code to list all the IP ranges in .cn, .in, ru “and a few others”). Listing the “acceptable” countries would also be difficult (long lines of code) but selecting only your target country would limit the list of countries.

Of course, using the geoIP API would resolve that problem for you … assuming you looked at the links I supplied for you.[/quote]

I did look at it.

I have no clue if it is installed on my VPS.

Yes…

I also asked why you didn’t have anything for the Allow directive.

I also asked if the absence of specific Allow would cause an issue.

What file am I looking for again? And where would I find it on my VPS?

Debbie

DD,

Regards,

DK

Thanks for the help David!!

Debbie