geoip2 /etc/nginx/geoip.mmdb {
	auto_reload 5m;
	$geoip2_metadata_country_build metadata build_epoch;
	$geoip2_data_country_code country iso_code;
}

map $geoip2_data_country_code $allowed_country {
	default {% if WHITELIST_COUNTRY != "" %}no{% else %}yes{% endif %};
	{% if WHITELIST_COUNTRY != "" %}
		{% for country in WHITELIST_COUNTRY.split(" ") %}
	{{ country }} yes;
		{% endfor %}
	{% endif %}
	{% if BLACKLIST_COUNTRY != "" %}
		{% for country in BLACKLIST_COUNTRY.split(" ") %}
	{{ country }} no;
		{% endfor %}
	{% endif %}
}
