How can we help you today?

How to Block Your Webshop for Specific Countries

Created by: Rens Zuurbier

Modified on: Wed, 27 May, 2020 at 2:31 PM

A lot of spam and abuse comes from specific countries. If you don't do business there, you could block these countries altogether. This article explains how to block them. First some considerations:

  • Country detection is 99,8% accurate (according to MaxMind, the supplier of the geo database).
  • It is generally better to servce a static page, than to enforce a hard block. Static pages consume almost no resources and can be used to explain alternative ways to contact your organisation.

If you want to block, say, Russia and China, create the files 'http.countries_map' and 'server.countries_block' in the nginx folder on your Hypernode. In these files you can use the following configuration:

In http.countries_map:

map $geoip_country_code $block_country {
    default no;
    CN yes;
    RU yes;

In server.countries_block:

if ($block_country = yes) {
    return 403;

Alternatively you can rewrite the request inside http.countries_map and upload a static "access_denied_for_country.html" page.

if ($block_country = yes) {
    rewrite ^ /access_denied_for_country.html break;
Rens is the author of this solution article.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.