/
Pack Hosting Panel

Block countries

How can you block traffic from certain countries at Hipex?


In practice, it is very common that websites are being overloaded with requests from bots that have nothing to do with those websites. These bots often come from one or more countries. You can find these countries in the access logs.

Of course, we developed some useful tools for Hipex CLI to block requests from one or multiple countries. In this article, we explain how you can do this.

Block certain countries

If there are some countries you want to block, you can use the following command: hipex security:country:blacklist.

In case you want to block all countries, except some, you can use the following command: hipex security:country:whitelist.

Add countries to the list

To add countries to the existing list, you can make use of the --append option.

Below we add China to the blacklist:

hipex security:country:blacklist CN --append

In the next example, we block all countries, except the Netherlands and Germany:

hipex security:country:whitelist NL DE --append

Please note: Be careful with the whitelist command. You will block all countries, except the ones you have entered. Having the risk of blocking too many countries has a negative impact on the number of real visitors of your online store.

Removing countries from the list

To remove countries from the list, you can make use of the --remove option.

In the example below, we'll delete Hong Kong from the blacklist:

hipex security:country:blacklist HK --remove

And after that, we'll delete China from the whitelist:

hipex security:country:whitelist CN --remove

Set periods for blocks / whitelists

In addition to blocking and whitelisting countries, we also offer the option to indicate how long the block / whitelist should last. Use the --duration option to do this.

You can provide the duration in the following format:

  • +1 minute
  • +3 hours
  • +1 year

Below, we'll add China to the blacklist for the upcoming 17 minutes:

hipex security:country:blacklist CN --append --duration '+17 minutes'

In the meantime, the country can be removed manually, as described earlier.

Below, we'll block all traffic for the upcoming hour, excluding the Netherlands:

hipex security:country:whitelist NL --append --duration '+1 hour'

After one hour, all countries will automatically have access again.