Hi there,
Thanks for building a really great integration with Fail2ban!
So I have had this working for a while on other OS distributions, but recently we upgraded some servers to Debian 12, and it stopped working.
The main issue is that Debian 12 no longer uses systemd. I found a workaround by installing perl-systemd
so that is now integrating the messages into Journalctl.
After reading some forums I read that you suggested to use LOG_LOCAL0
as the output to get them into the actual JournalCtl logs. This is working now in terms of reporting the messages properly to JournalCtl.
I still couldn’t get the fail2ban configurations to work afterwards though. So I contacted Fail2ban via this issue, and after making additional changes I was able to make fail2ban to read the messaging.
I wanted to report it back here just to be complete for others not to spend the numerous hours I did. Also, Serge suggested a few things that I think “might” be relevant or helpful for the existing plugin.
Suggestions:
- Use one regex line to optimize speed (see below)
- Remove the
_daemon
trigger since we can use the Regex to actually retrieve/ignore it - Use
<ADDR>
in light of<HOST>
because it is also faster, but maybe there is a reason you are using<HOST>
?
My changes:
- I couldn’t use the
%(__prefix_lines)
because it was failing on the date output. In my case it was like2024-06-06T07:39:58.980111-04:00
, and in common.conf it doesn’t seem to have a proper date formatting. Then I realized that we don’t really need that and could just throw the entire parsing into the regex and be somewhat independent, but I don’t know if this works on other OSs (that would need testing) - Changed
backend
to usebackend= systemd
in the filter configuration - Added a
journalmatch = SYSTEMD_UNIT=php8.0-fpm.service
to target the proper journal. I couldn’t leave it blank since the conf fails, and I could never getlogpath
to work
Jail configuration
[wordpress-hard]
enabled = true
filter = wordpress-hard
backend = systemd
journalmatch = _SYSTEMD_UNIT=php8.0-fpm.service
maxretry = 1
port = http,https
[wordpress-soft]
enabled = true
filter = wordpress-soft
backend = systemd
journalmatch = _SYSTEMD_UNIT=php8.0-fpm.service
maxretry = 5
port = http,https
[wordpress-extra]
enabled = true
filter = wordpress-extra
backend = systemd
journalmatch = _SYSTEMD_UNIT=php8.0-fpm.service
maxretry = 3
port = http,https
wordpress-soft.conf
# Fail2Ban filter for soft failures
# Auto-generated: 2024-01-28T18:48:23+00:00
#
[INCLUDES]
before = common.conf
[Definition]
failregex = ([^\s]+)\s+(?:wordpress|wp)(?:\([^\)]*\))?\[\d+\]: (?:Emptyusername|Authentication failure for .*|REST authentication failure for .*|XML-RPC authentication failure for .*|Authentication attempt for unknown user .*|Blocked username authentication attempt for .*|Pingback requested from|Comment attempt on .* post \d+) from <ADDR>$
ignoreregex =
wordpress-hard.conf
# Fail2Ban filter for hard failures
# Auto-generated: 2024-01-28T18:48:23+00:00
#
[INCLUDES]
before = common.conf
[Definition]
failregex = ([^\s]+)\s+(?:wordpress|wp)(?:\([^\)]*\))?\[\d+\]: (?:Untrusted X-Forwarded-For header|REST authentication attempt for unknown user .*|XML-RPC authentication attempt for unknown user .*|Immediately block connections|Blocked access from country '..'|XML-RPC request blocked|.*; Bogus Pingback|Akismet discarded spam comment|Spam comment \d+|Blocked authentication attempt for .*|XML-RPC multicall authentication failure|Pingback error .* generated|Blocked user enumeration attempt) from <ADDR>$
ignoreregex =
wordpress-extra.conf
# Fail2Ban filter for extra failures
# Auto-generated: 2024-01-28T18:48:23+00:00
#
[INCLUDES]
before = common.conf
[Definition]
failregex = ([^\s]+)\s+(?:wordpress|wp)(?:\([^\)]*\))?\[\d+\]: (?:Password reset requested for .*|Comment \d+) from <ADDR>$
ignoreregex =