Для «ХостПлюс» мы создали кастомные фильтры для трёх основных векторов атак.
Nginx 4xx — блокировка сканеров:
# /etc/fail2ban/filter.d/nginx-4xx.conf
[Definition]
failregex = ^ - .* "(GET|POST|HEAD|PUT|DELETE) .+" (400|401|403|404|405|444) .*$
ignoreregex = ^ - .* "GET /favicon\.ico" 404
^ - .* "GET /robots\.txt" 404
# /etc/fail2ban/jail.d/nginx-4xx.local
[nginx-4xx]
enabled = true
port = http,https
logpath = /var/log/nginx/access.log
filter = nginx-4xx
maxretry = 20
findtime = 60
bantime = 7200
WordPress wp-login.php — защита от подбора паролей:
# /etc/fail2ban/filter.d/wordpress.conf
[Definition]
failregex = ^ - .* "POST /wp-login\.php HTTP/.*" (200|302) .*$
^ - .* "POST /xmlrpc\.php HTTP/.*" 200 .*$
ignoreregex =
# /etc/fail2ban/jail.d/wordpress.local
[wordpress]
enabled = true
port = http,https
logpath = /var/log/nginx/access.log
filter = wordpress
maxretry = 5
findtime = 120
bantime = 86400
# Отдельный jail для xmlrpc (более агрессивный)
[wordpress-xmlrpc]
enabled = true
port = http,https
logpath = /var/log/nginx/access.log
filter = wordpress[mode=xmlrpc]
maxretry = 2
findtime = 60
bantime = 604800
Postfix SASL — защита почтового сервера:
# /etc/fail2ban/filter.d/postfix-sasl.conf
[Definition]
failregex = ^.*warning: [-._\w]+\[\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed:.*$
^.*reject: RCPT from [-._\w]+\[\]: 554 5\.7\.1.*$
^.*reject: RCPT from [-._\w]+\[\]: 450 4\.7\.1.*Client host rejected.*$
ignoreregex =
# /etc/fail2ban/jail.d/postfix.local
[postfix-sasl]
enabled = true
port = smtp,465,587,submission
logpath = /var/log/mail.log
filter = postfix-sasl
maxretry = 3
findtime = 600
bantime = 86400
Оставить комментарий