Concernant le fichier Jeedom.conf, j’ai perso fait quelques adaptations.
Pour la partie :
# Ne pas activer cette regle qui bloque l'accès a jeedom trop facile a cause d'erreur de type [access_compat:error] [pid 10800] [client 192.168.0.67:62801] AH01797: client denied by server configuration: /var/www/html/plugins/zigbee/core/config/devices/undefined, referer: http://192.168.0.49/index.php?v=d&p=zigbee&m=zigbee&id=189
#[apache-multiport]
#enabled = false
Je l’ai remplacée par une jail (apache-clientd) avec son fichier de configuration spécifique apache-client-denied.conf à placer dans /etc/fail2ban/filter.d/
Contenu de apache-client-denied.conf :
#############################################
# Fail2ban configuration file
#
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from common.local
before = apache-common.conf
[Definition]
# Option: failregex
# Notes.: regex to match the password failure messages in the logfile. The host must be matched by a group named "host".
# The tag "<HOST>" can be used for standard IP/hostname matching and is only an alias for (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
# Values: TEXT
#
failregex = .*\[client <HOST>:\d+\] AH01797: client denied by server configuration.*$
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =
#############################################
Ceci etant fait, rajouter la prise en compte de la jail apache-clientd dans jeedom.conf :
# Block repetitive : client denied by server configuration
[apache-clientd]
enabled = true
port = http,https
filter = apache-client-denied
logpath = /var/www/html/log/http*.error
maxretry = 3
action = iptables[name=HTTP, port=http, protocol=tcp]
# bantime = 3600
Autre point qui peut-être mis en place : le banissement avec durée incrémentale
Cela évite de banir des IP avec des durées sans fin, ce qui est contre-productif.
Avec ce type de banissement, plus tu viens souvent, plus tu es puni longtemps.
Cela se configure dans le fichier jeedom.conf en y ajoutant :
# bannissement incremental
bantime.increment = true
# facteur d'incrementation
# default factor (causes increment - 1h -> 1d 2d 4d 8d 16d 32d ...):
bantime.factor = 24
# banissement maxi = 5 semaines
bantime.maxtime = 5w
Le facteur incremental bantime.factor (que j’ai fixé à 24) fonctionne ainsi :
Si bantime = 1h
- 1er ban : 1h * 24 * 2^0 → 1 * 24 * 1 → 24h ->1j
- 2eme ban : 1h * 24 * 2^1 → 1 * 24 * 2 → 48h ->2j
- 3eme ban : 1h * 24 * 2^2 → 1 * 24 * 4 → 96h ->4j
- 4eme ban : 1h * 24 * 2^3 → 1 * 24 * 8 → 192h → 8j
- 5eme ban : 1h * 24 * 2^4 → 1 * 24 * 16 → 384h → 16j
- 6eme ban : 1h * 24 * 2^5 → 1 * 24 * 32 → 768h → 32j
- 7eme ban : 1h * 24 * 2^6 → 1 * 24 * 64 → 1536h → 64j → limité à 5 semaines par bantime.maxtime = 5w
Au final ça donne un fichier jeedom.conf de ce type :
[DEFAULT]
#Ne pas bloquer localhost ni s'auto-bloquer.
ignoreip = 127.0.0.1/8 192.168.1.0/24 192.168.0.0/24 10.0.0.0/8
# ban de 480 minutes soit 8h
bantime = 28800
# bannissement incremental
bantime.increment = true
# facteur d'incrementation
# default factor (causes increment - 1h -> 1d 2d 4d 8d 16d 32d ...):
bantime.factor = 24
# banissement maxi = 5 semaines
bantime.maxtime = 5w
# on regarde les attaques sur les 2 dernières heures. Les 5 minutes par défaut, ça ne marche plus, les pirates se sont adaptés
findtime = 7200
maxretry = 3
# on surveille tous les ports
banaction = iptables-multiport
# action a prendre: ban + log détaillé
action = %(action_)s
# Ne pas activer cette regle qui bloque l'accès a jeedom trop facile a cause d'erreur de type [access_compat:error] [pid 10800] [client 192.168.0.67:62801] AH01797: client denied by server configuration: /var/www/html/plugins/zigbee/core/config/devices/undefined, referer: http://192.168.0.49/index.php?v=d&p=zigbee&m=zigbee&id=189
#[apache-multiport]
#enabled = false
#port = http,https
#filter = apache-auth
#logpath = /var/www/html/log/http*.error
#maxretry = 3
[apache-botsearch]
enabled = true
port = http,https
filter = apache-botsearch
logpath = /var/www/html/log/http*.error
maxretry = 6
[apache-overflows]
enabled = true
port = http,https
filter = apache-overflows
logpath = /var/www/html/log/http*.error
maxretry = 2
[apache-noscript]
enabled = true
port = http,https
filter = apache-noscript
logpath = /var/www/html/log/http*.error
maxretry = 1
# Block repetitive : client denied by server configuration
[apache-clientd]
enabled = true
port = http,https
filter = apache-client-denied
logpath = /var/www/html/log/http*.error
maxretry = 3
action = iptables[name=HTTP, port=http, protocol=tcp]
# bantime = 3600
Avec cette configuration, je n’ai pas constaté de problème ni de faux-positifs et l’efficacité est plutôt bonne. Je suis en général à près de 200 IP bannies en permanence.
Si cela peut t’aider à peaufiner ta configuration.