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
| SitePoint Sponsor |





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
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator
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?
How reliably can I say, "Block everyone coming from China"??Unfortunately, you'll find that there are a huge list of blocks (for each)
I have a VPS, so how would I do that?and really should block in the server's conf (or your vhosts.conf) file.
Regards,
DK
Debbie

David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator





But don't I have a reasonable concern??
Why would anyone in Russia, China, Iran, etc want to visit my site - which is for U.S.-only consumption - unless they have nefarious intent?
What does <directory> do?Originally Posted by dklynn
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...
Code: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/count...elect-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
David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator





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.
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...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
Can we go over this again...
Code:<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...
...what would happen?Code:Options FollowSymLinks AllowOverride All
3.) This code...
...says, "Perform Deny directives first and then do Allow directives next, right?Code:Order deny,allow
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...
Code:Order deny,allow
Or does the order of the following lines matter to...
Thanks,Code:Deny from all Allow from example.com
Debbie

David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator





Well, I didn't know that. That is why I was asking!
That makes total sense.
Sounds like using .htaccess is evil...
I did look at it.Originally Posted by dklynn
I have no clue if it is installed on my VPS.
Yes....Originally Posted by doubledee
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?Originally Posted by doubledee
Debbie

David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
Client and (unpaid) WHB Ambassador
Updated mod_rewrite Tutorial Article (setup, config, test & write
mod_rewrite regex w/sample code) and Code Generator





Thanks for the help David!!
Debbie
Bookmarks