WP_FAIL2BAN_EX_BLOCK_COUNTRIES

Block requests from specified countries.

Default setting: disabled

Premium flavour only


Returns HTTP 403 for requests whose resolved country appears in this list. Country resolution follows WP_FAIL2BAN_EX_GEOLOCATION: it can use the local MaxMind database, a trusted Cloudflare country header, or the configured combination. A MaxMind licence is therefore not required for a working Cloudflare-only policy.

Do not put the same country in this list and WP_FAIL2BAN_EX_BLOCK_COUNTRIES_451. If an overlap exists, this HTTP 403 list takes precedence.

Example: Block requests from specific countries
/**
 * Block requests from specified countries
 */
define('WP_FAIL2BAN_EX_BLOCK_COUNTRIES', [
    'RU',  // Russia
    'CN',  // China
    'KP'   // North Korea
]);

Note

Country codes must be specified using ISO 3166-1 alpha-2 format.

History

Added in version 4.3.2.0.