Score:0

Fail2ban make a custom fail regex filter for Nginx error log

tg flag

I am new to regex. How do I write a Fail2Ban filter to match with these nxinx error log lines?

2022/11/30 00:46:19 [crit] 57811#57811: *8911 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking, client: 64.62.197.168, server: 0.0.0.0:443

and:

2022/11/30 02:26:52 [error] 57811#57811: *8939 upstream timed out (110: Connection timed out) while SSL handshaking to upstream, client: 77.88.5.11, server: xxxxxxxxx.com, request: "GET /robots.txt HTTP/1.1", upstream: "https://0.0.0.0:5000/robots.txt", host: "xxxxxxxxx.com"

The current filter does not catch any of these lines when I use fail2ban-regex to test:

Results
=======

Failregex: 0 total

Ignoreregex: 0 total

Date template hits:
|- [# of hits] date format
|  [21] {^LN-BEG}ExYear(?P<_sep>[-/.])Month(?P=_sep)Day[T ]24hour:Minute:Second(?:[.,]Microseconds)?(?:\s*Zone offset)?
`-

Lines: 21 lines, 0 ignored, 0 matched, 21 missed
[processed in 0.00 sec]

|- Missed line(s):
|  2022/11/30 00:46:19 [crit] 57811#57811: *8911 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking, client: 64.62.197.168, server: 0.0.0.0:443
|  2022/11/30 02:26:52 [error] 57811#57811: *8939 upstream timed out (110: Connection timed out) while SSL handshaking to upstream, client: 77.88.5.11, server: xxxxxxxxx.com, request: "GET /robots.txt HTTP/1.1", upstream: "https://0.0.0.0:5000/robots.txt", host: "xxxxxxxxx.com"
|  2022/11/30 02:27:53 [error] 57811#57811: *8942 upstream timed out (110: Connection timed out) while SSL handshaking to upstream, client: 93.158.161.40, server: xxxxxxxxx.com, request: "GET /robots.txt HTTP/1.1", upstream: "https://0.0.0.0:5000/robots.txt", host: "xxxxxxxxx.com"
|  2022/11/30 02:29:53 [error] 57811#57811: *8946 upstream timed out (110: Connection timed out) while SSL handshaking to upstream, client: 77.88.5.133, server: xxxxxxxxx.com, request: "GET / HTTP/1.1", upstream: "https://0.0.0.0:5000/", host: "xxxxxxxxx.com"```

(I replaced my domain name with xxxxxxxxx in the above output)

Thanks!

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.