Blocking Countries
To block visitors from a specific country, or multiple countries, create or upload a file to wp-content named .nginx-block-country
. This happens on the server level and is more effective than a plugin, plus the visitor does not get to the site to take up any resources.
The file:
map $geoip2_data_country_code $block_country { default 0; CN 1; VN 1; }
To add a country, add the 2-character ISO code, followed with 1 and semicolon, for example, for China use CN 1;
. In the example code above, we've added China and Vietnam.
Go to the WP-CLI tab and click on Restart Workers in the toolbar to clear the cache.