Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Using a Fail2ban jail to mitigate against simple DoS attacks against Apache
# Fail2Ban filter to scan Apache access.log for DoS attacks
before = common.conf
# Option: failregex
# Notes.: regex to match GET requests in the logfile resulting in one of the
# following status codes: 401, 403, 404, 503.
# 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
# see
failregex = ^<HOST> .*"GET (?!\/robots\.txt).*" (401|403|404|503)\s
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
ignoreregex =
enabled = true
port = http,https
filter = apache-get-dos
logpath = /var/www/*/logs/access.log
datepattern = %%d/%%b/%%Y:%%H:%%M:%%S %%z
maxretry = 300
findtime = 5m
bantime = 1h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment