# The below config is for geoblocking any country/city you add. The default config is blocking all countries/cities except the ones you set to "yes".
# If you want to do the opposite, set default to "yes", and the countries/cities to "no".
# As the default config blocks all IP's except the ones in the GeoLite2-City.mmdb database set to yes, you will need to allow your lan ip for local access.
geoip2 /config/geoip2db/GeoLite2-City.mmdb {
auto_reload 5m;
$geoip2_data_country_code country iso_code;
$geoip2_data_city_name city names en;
}
# GEOIP2 COUNTRY CONFIG
map $geoip2_data_country_code $allowed_country {
default no;
<COUNTRY-CODE> yes; # e.g GB yes; for United Kingdom
IP/CIDR yes; # e.g. 192.168.1.0/24 yes; for local access.
}
#(Optional)
# GEOIP2 CITY CONFIG
# map $geoip2_data_city_name $allowed_city {
# default no;
# <CITY-NAME> yes; # e.g Inverness yes;
# IP/CIDR yes; # e.g. 192.168.1.0/24 yes; for local access.
# }
# Server config example:
# Add the following if statement inside any server context you want to geo block.
# COUNTRY GEO BLOCK
# if ($allowed_country = no) {
# return 444;
# }
# Full example:
# sample config for "default" with the geo block added
#server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
#
# root /config/www;
# index index.html index.htm index.php;
#
# server_name _;
# COUNTRY GEO BLOCK
# if ($allowed_country = no) {
# return 444;
# }
# # enable subfolder method reverse proxy confs
# include /config/nginx/proxy-confs/*.subfolder.conf;