By grammer
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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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
Hello there,
In order to block a country, you can use the CC_DENY option which accepts two-letter country codes such as US, GB and etc.
In order to list more than one country you just need to separate them using comas:
CC_DENY = "AB,CD,EF"
You may find a list of ISO 3166-1 alpha-2 code at https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
If you’re not familiar with CSF or you want to install it on CentOS or Ubuntu droplet check out this mini tutorial:
For CentOS:
Hope that this helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.