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.
If there are some countries you want to block, you can use the following command:
In case you want to block all countries, except some, you can use the following command:
To add countries to the existing list, you can make use of the
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.
To remove countries from the list, you can make use of the
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
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.