Realized that a lot of bots are coming from countries the shop does not ship to. Some are harmless crawlers (e.g. Russian, Chinese Search Engine bots) but often a lot of vulnerability search crawlers access site.

  1. What is the BEST way to block majority of countries?
  2. Is there a suggested list of such countries ?
  3. Are there future BAD implications due to blocking a bunch of countries?

always use firewall to block ip/cidr or country. like hardware firewall with your hosting provider or local software firewall installation like CSF Firewall. NEVER use http/webserver app.

in CSF Firewall you just enter this:


install ipset module to keep millions ips in iptables without any performance degradation. enable it:

LF_IPSET = "1"

then enable blocklist, it will ban every bad ip from honeypots list with weekly updates:

sed -i "/|0|/s/^#//g" /etc/csf/csf.blocklists

then also it has lots of features to enable traffic and connections tracking, and will ban any ip that opens more connections than you define. etc

you will have to check with your services and modules if they use their API or connections in/to blocked countries. and whitelist their networks.


Here's one answer why NOT to block traffic:

If you have decided to block then one of the options would be on Apache level and using Maxmind's mod:

This has also example how to block certain countries.

If you are using Varnish then this could happen on this level (instead of Apache):


To add some word to Elvin Risti answer's, that make clear you shouldn't block contries : if you really want to do so, please take a look a this nice script

Connects MaxMind GeoIP DB to Magento

with this, you can change your index.php at root of magento and block people on their IPs. Should do the work for robots, but not for real people that couls use proxys or VPNs. These was tested on magento but could bu used in most any 1.x version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.