Skip to content

Instantly share code, notes, and snippets.

@trexx
Created December 20, 2017 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trexx/3b89778ffd428fa076767af13080e5c7 to your computer and use it in GitHub Desktop.
Save trexx/3b89778ffd428fa076767af13080e5c7 to your computer and use it in GitHub Desktop.
Fail2Ban using ngx_http_access_module.
# Fail2Ban configuration file
#
# Author: Turan Asikoglu
#
#
[Definition]
# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#
actionstart = touch <file>
# Option: actionstop
# Notes.: command executed once at the end of Fail2Ban
# Values: CMD
#
actionstop = touch <file>
# Option: actioncheck
# Notes.: command executed once before each actionban command
# Values: CMD
#
actioncheck =
# Option: actionban
# Notes.: command executed when banning an IP. Take care that the
# command is executed with Fail2Ban user rights.
# Tags: See jail.conf(5) man page
# Values: CMD
#
actionban = printf %%b "deny <ip>;\n" >> <file>
nginx -s reload
# Option: actionunban
# Notes.: command executed when unbanning an IP. Take care that the
# command is executed with Fail2Ban user rights.
# Tags: See jail.conf(5) man page
# Values: CMD
#
actionunban = echo "/deny <ip>;$/<br>d<br>w<br>q" | ed <file>
nginx -s reload
[Init]
# Option: file
# Notes.: fail2ban-blacklist.conf file path.
# Values: STR Default: /etc/nginx/fail2ban-blacklist.conf
#
file = /etc/nginx/fail2ban-blacklist.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment