mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-03-14 17:27:23 +01:00
Merge changes from kiekerjan special
This commit is contained in:
12
conf/fail2ban/filter.d/nginx-geoipblock.conf
Normal file
12
conf/fail2ban/filter.d/nginx-geoipblock.conf
Normal file
@@ -0,0 +1,12 @@
|
||||
# Fail2Ban filter Mail-in-a-Box geo ip block
|
||||
|
||||
[INCLUDES]
|
||||
|
||||
before = common.conf
|
||||
|
||||
[Definition]
|
||||
|
||||
_daemon = mailinabox
|
||||
|
||||
failregex = .* - Geoip blocked <HOST>
|
||||
ignoreregex =
|
||||
10
conf/fail2ban/filter.d/ssh-geoipblock.conf
Normal file
10
conf/fail2ban/filter.d/ssh-geoipblock.conf
Normal file
@@ -0,0 +1,10 @@
|
||||
# Fail2Ban filter sshd ip block according to https://www.axllent.org/docs/ssh-geoip/
|
||||
|
||||
[INCLUDES]
|
||||
|
||||
before = common.conf
|
||||
|
||||
[Definition]
|
||||
|
||||
failregex = .* DENY geoipblocked connection from <HOST>
|
||||
ignoreregex =
|
||||
9
conf/fail2ban/jail.d/nginx-general.conf
Normal file
9
conf/fail2ban/jail.d/nginx-general.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
[nginx-badbots]
|
||||
enabled = true
|
||||
port = http,https
|
||||
filter = nginx-badbots
|
||||
logpath = /var/log/nginx/access.log
|
||||
maxretry = 2
|
||||
|
||||
[nginx-http-auth]
|
||||
enabled = true
|
||||
3
conf/geoiplookup.conf
Normal file
3
conf/geoiplookup.conf
Normal file
@@ -0,0 +1,3 @@
|
||||
# UPPERCASE space-separated country codes to ACCEPT
|
||||
# See e.g. https://dev.maxmind.com/geoip/legacy/codes/iso3166/ for allowable codes
|
||||
ALLOW_COUNTRIES=""
|
||||
@@ -9,6 +9,30 @@
|
||||
rewrite ^/admin$ /admin/;
|
||||
rewrite ^/admin/munin$ /admin/munin/ redirect;
|
||||
location /admin/ {
|
||||
# By default not blocked
|
||||
set $block_test 1;
|
||||
|
||||
# block the continents
|
||||
if ($allowed_continent = no) {
|
||||
set $block_test 0;
|
||||
}
|
||||
|
||||
# in addition, block the countries
|
||||
if ($denied_country = no) {
|
||||
set $block_test 0;
|
||||
}
|
||||
|
||||
# allow some countries
|
||||
if ($allowed_country = yes) {
|
||||
set $block_test 1;
|
||||
}
|
||||
|
||||
# if 0, then blocked
|
||||
if ($block_test = 0) {
|
||||
access_log /var/log/nginx/geoipblock.log geoipblock;
|
||||
return 444;
|
||||
}
|
||||
|
||||
proxy_pass http://127.0.0.1:10222/;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
add_header X-Frame-Options "DENY";
|
||||
|
||||
22
conf/nginx/conf.d/10-geoblock.conf
Normal file
22
conf/nginx/conf.d/10-geoblock.conf
Normal file
@@ -0,0 +1,22 @@
|
||||
# GeoIP databases
|
||||
geoip_country /usr/share/GeoIP/GeoIP.dat;
|
||||
geoip_city /usr/share/GeoIP/GeoIPCity.dat;
|
||||
|
||||
# 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 the list of allowed countries
|
||||
map $geoip_country_code $allowed_country {
|
||||
default no;
|
||||
}
|
||||
|
||||
# map the continents to allow
|
||||
map $geoip_city_continent_code $allowed_continent {
|
||||
default yes;
|
||||
}
|
||||
|
||||
log_format geoipblock '[$time_local] - Geoip blocked $remote_addr';
|
||||
Reference in New Issue
Block a user