Is it possible to block access to my website for specific country?

Posted June 2, 2015 8.8k views
SecurityConfiguration Management

Are there any settings for docker to block access to my website for specific country?

Or I need to do all programming myself? Is it optimal to create a block in .htaccess?

Or which 3rd party services to use. Preferably free, of course.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Yes. You can use a firewall like iptables to block the IP address blocks associated with a country. This process is not 100% as any users using a VPN outside their country, using a service like TOR or a web proxy outside their country would still be able to access your server since they would not be assigned an IP address associated with their country.

I found this guide that should be helpful.

This references blocking Chinese IPs and the script near the bottom uses a third party service to source the IP lists. These can be found here.

Found a solution - I had Prestashop, and just wanted to block specific country. Appeared it is native setting in Preferences→Geolocation