Skip to content

Instantly share code, notes, and snippets.

@jas8522
Forked from gbot/wp-xmlrpc-jail.local
Last active September 3, 2018 15:05
Show Gist options
  • Save jas8522/f638d8e3192a0e44ebe3849b1c32e45a to your computer and use it in GitHub Desktop.
Save jas8522/f638d8e3192a0e44ebe3849b1c32e45a to your computer and use it in GitHub Desktop.
Fail2Ban WordPress XMLRPC Jail and Filter. Notes: log path is set for Plesk v12+. Adjusted to work with a 'normal' xmlrpc request hit rate and only ban when beyond normal.
[ws-wp-xmlrpc]
enabled = true
filter = ws-wp-xmlrpc
action = iptables-multiport[name=wp-xmlrpc, port="http,https"]
logpath = /var/www/vhosts/system/*/logs/*access*log tail
/var/log/httpd/*access_log tail
# If there are 50 hits in 30 seconds (1.66/s), ban the IP for 30 minutes
bantime = 1800
maxretry = 50
findtime = 30
# Fail2Ban filter for WordPress XMLRPC
[INCLUDES]
before = common.conf
[Definition]
failregex = ^<HOST>.* "POST .*/xmlrpc\.php.*
# Allow JetPack and FooEvents
ignoreregex = ^<HOST>.*] "POST /xmlrpc\.php?for=jetpack.*
ignoreregex = ^<HOST>.*] "POST /xmlrpc\.php?.*FooEvents_app.*
# Original Rule Author: Gavin Botica
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment