Using fail2ban to Protect WordPress from Brute Force Attacks

Super quick guide on how to set up fail2ban to protect your server from WordPress brute force attacks. This guide assumes use of Apache and CentOS.

Install fail2ban if it is not installed already, then add this configuration file:


and these contents:

 failregex = ^<HOST> .* "POST /wp-login.php.*$
 ignoreregex =

Append or add this file:


and the contents:

 enabled = true
 filter = wp-login
 action = iptables-multiport[name=NoAuthFailures, port="https,https"]
 logpath = /var/log/httpd/*access*.log
 findtime = 60
 bantime = 86400
 maxretry = 3

fail2ban uses the sites access logs to check. This is set up to check all access logs in the /var/log/httpd folder. Adjust this rule based on your server’s log location and configuration (not the wildcard *).

Finally restart fail2ban

service fail2ban restart


systemctl restart fail2ban
Triple H would approve of fail2ban
Triple H would approve of fail2ban


Leave a Reply

Your email address will not be published. Required fields are marked *