Skip to content

Instantly share code, notes, and snippets.

@xros
Forked from Swop/jail.local
Last active October 24, 2020 07:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xros/56260c67125ff4d2a3a9 to your computer and use it in GitHub Desktop.
Save xros/56260c67125ff4d2a3a9 to your computer and use it in GitHub Desktop.
Adds Nginx DOS detection to Fail2ban
# /etc/fail2ban/jail.local
# [...]
[nginx-dos]
# Based on apache-badbots but a simple IP check (any IP requesting more than
# 240 pages in 60 seconds, or 4p/s average, is suspicious)
# Block for two full days.
# @author xros
enabled = true
port = http,https
filter = nginx-dos
logpath = /srv/data-srv1/logs/nginx/*/*access.log
findtime = 60
bantime = 172800
maxretry = 240
# /etc/fail2ban/filter.d/nginx-dos.conf
# Fail2Ban configuration file
#
# Generated on Fri Jun 08 12:09:15 EST 2012 by BeezNest
#
# Author: Yannick Warnir
#
# $Revision: 1 $
#
[Definition]
# Option: failregex
# Notes.: Regexp to catch a generic call from an IP address.
# Values: TEXT
#
failregex = ^<HOST> -.*"(GET|POST).*HTTP.*"$
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment