Ein wenig Google hilft:
Fail2Ban is an effective security tool for protecting WordPress sites from brute-force attacks and other malicious activities. It works by monitoring log files for suspicious activity and automatically banning IP addresses that exceed a predefined threshold of failed login attempts.
## Overview of Fail2Ban
Fail2Ban operates by creating "jails," which are configurations that specify which log files to monitor, the patterns of suspicious activity to look for (using regex), and the actions to take when an attack is detected. It can modify firewall rules to block offending IP addresses, thereby reducing the load on the server and preventing unauthorized access.
## Setting Up Fail2Ban for WordPress
### 1. Installation
To install Fail2Ban on an Ubuntu server, you can use the following command:
```bash
sudo apt-get install fail2ban
```
### 2. Configuring Fail2Ban for WordPress
After installation, you need to create a filter and a jail configuration for WordPress.
#### Create a Filter
Create a filter file at `/etc/fail2ban/filter.d/wordpress.conf` with the following content:
```ini
[Definition]
failregex = ^<HOST> .* "(GET|POST) /+wp-login.php
^<HOST> .* "(GET|POST) /+xmlrpc.php
ignoreregex =
```
This configuration will detect failed login attempts to `wp-login.php` and `xmlrpc.php`.
#### Create a Jail Configuration
Edit the jail configuration file, usually located at `/etc/fail2ban/jail.local`, and add the following:
```ini
[wordpress]
enabled = true
filter = wordpress
logpath = /var/log/apache2/access.log # Adjust based on your server's log path
maxretry = 5
findtime = 600
bantime = 3600
action = iptables[name=WordPress, port=http, protocol=tcp]
```
This configuration enables the WordPress jail, specifies the log file to monitor, and sets the parameters for retries, time to find failed attempts, and the ban duration.
### 3. Restart Fail2Ban
After making these changes, restart the Fail2Ban service to apply the new configurations:
```bash
sudo systemctl restart fail2ban
```
### 4. Monitoring Fail2Ban
You can check the status of your Fail2Ban jails to see if they are working correctly:
```bash
fail2ban-client status wordpress
```
This command will show you the number of currently banned IPs and other statistics related to the WordPress jail.
## Additional Recommendations
- **Using Plugins**: The WP fail2ban plugin can also be installed to integrate Fail2Ban directly with WordPress, enhancing logging and providing additional configuration options[1][4].
- **Combine with Other Security Measures**: While Fail2Ban is effective, it is advisable to use it alongside other security measures like strong passwords, web application firewalls (WAFs), and security plugins such as Wordfence to provide comprehensive protection against various types of attacks[2][3].
By implementing Fail2Ban and configuring it properly, you can significantly enhance the security of your WordPress site against brute-force attacks and unauthorized access attempts.
Citations:
[1]
https://wordpress.org/plugins/wp-fail2ban/
[2]
https://www.dogsbody.com/blog/how-to-se ... ress-site/
[3]
https://runcloud.io/blog/fail2ban-wordpress-cloudflare
[4]
https://www.digitalocean.com/community/ ... untu-14-04
[5]
https://forum.hestiacp.com/t/has-anyone ... press/3519