-
I'm trying to make a simple fail2ban filter to block wordpress on my server, but it doesn't seem to work, can you help me understand why? can be the "-"? Should be escaped somehow?
Other fail2ban filters work. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The main reason is you trying to find it in the agent part (3rd group enclosed in quotes), so Try something like this: - failregex = ^(?:\[[^\]]*\] )?<ADDR> [^"]*"[^"]*" \d+ \S+ "[^"]*" "[^"]*(?:%(others)s|%(wpblock)s)[^"]*"$
+ failregex = ^(?:\[[^\]]*\] )?<ADDR> [^"]*"[^"]*(?:%(others)s|%(wpblock)s)[^"]*" (?!200) ( However it still looks a bit ugly too me (the part Also note that monitoring of accesslog directly is not recommended, see wiki :: Best practice... For instance, one could deny unwanted responses on side of web-server. and write forbidden requests to different log (much smaller than your accesslog), and then ban everything matched in this log. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much, I could have watched it for years and never noticed... 200 is useless because I don't allow wordpress on my server, so every request to wordpres is a bad intention. 301 is because they search without www, and all my websites redirect to www. |
Beta Was this translation helpful? Give feedback.
The main reason is you trying to find it in the agent part (3rd group enclosed in quotes), so
[^"]*"[^"]*" \d+ \S+ "[^"]*"
would bypass the "URI-part", response code (\d
), size, "referrer" and then search for%(wpblock)s
inside the "agent"...Try something like this:
(
[^"]*
- bypass anything but not"
-char, then match"
-char (open quote for method+URI-part), then again anything but not"
, then the string matching others or wpblock ...)However it still looks a bit ugly too me (the part
(?:%(othe…