1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-04-02 21:37:23 +02:00

move nginx geoip blocking to GeoIP database version 2, simplyfing geoip installation

This commit is contained in:
KiekerJan
2023-03-10 21:33:08 +01:00
parent 4e4055b956
commit 87d871a480
6 changed files with 31 additions and 71 deletions

View File

@@ -1,22 +1,26 @@
# GeoIP databases
geoip_country /usr/share/GeoIP/GeoIP.dat;
geoip_city /usr/share/GeoIP/GeoIPCity.dat;
geoip2 /usr/share/GeoIP/GeoLite2-Country.mmdb
{
$geoip_country_code_x country iso_code;
$geoip_continent_code_x continent code;
}
# map the list of denied countries
# see e.g. https://dev.maxmind.com/geoip/legacy/codes/iso3166/ for allowable
# countries
map $geoip_country_code $denied_country {
default yes;
map $geoip_country_code_x $denied_country {
default yes; # Add denied countries with no
}
# map the list of allowed countries
map $geoip_country_code $allowed_country {
default no;
map $geoip_country_code_x $allowed_country {
default no; # Add allowed countries with yes
}
# map the continents to allow
map $geoip_city_continent_code $allowed_continent {
default yes;
map $geoip_city_continent_code_x $allowed_continent {
default yes; # Add allowed continents with yes.
}
log_format geoipblock '[$time_local] - Geoip blocked $remote_addr';
log_format geoipblock '[$time_local] - Geoip blocked $remote_addr - $geoip_country_code_x';
log_format geoipaccept '[$time_local] - Geoip accepted $remote_addr - $geoip_country_code_x';