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

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.

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Hello there,

You can also use third-party providers like CloudFlare that provider Firewall features that allow blocking single IP addresses or whole IP ranges.

Just enter an IP address, an IP range, or a two-letter country code you wish to block. You can check more here:

Hope that this helps!

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:


You may find a list of ISO 3166-1 alpha-2 code at

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!

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