Giter Club home page Giter Club logo

Comments (7)

sebres avatar sebres commented on June 16, 2024 1

the error log can not be changed in nginx and it always adds a timestamp to the error message

Imho, it depends on how the log-forwarding to syslog in configured.

Changing the start of the expression from ^\s*[error] to ^.*[error] resolves this problem and the filter matches.

This is ugly workaround, since the RE becomes vulnerable due to broken anchor - because ^.* is quasi the same as if it were missing, so no anchor anymore and REs may match everywhere (also against a user input with an "injection" attempt), additionally it becomes very slow, especially on long messages, since it must search the whole message.

Anyway for people having that format here is interim workaround:

- mdre-auth = ^\s*\[error\] \d+#\d+: \*\d+ user "(?:[^"]+|.*?)":? (?:password mismatch|was not found in "[^\"]*"), client: <HOST>, server: \S*, request: "\S+ \S+ HTTP/\d+\.\d+", host: "\S+"(?:, referrer: "\S+")?\s*$
+ mdre-auth = ^\s*(?:(?!\[)\S+ nginx\[\d+\]: [^\[]*)?\[error\] \d+#\d+: \*\d+ user "(?:[^"]+|.*?)":? (?:password mismatch|was not found in "[^\"]*"), client: <HOST>, server: \S*, request: "\S+ \S+ HTTP/\d+\.\d+", host: "\S+"(?:, referrer: "\S+")?\s*$
- mdre-fallback = ^\s*\[crit\] \d+#\d+: \*\d+ SSL_do_handshake\(\) failed \(SSL: error:\S+(?: \S+){1,3} too (?:long|short)\)[^,]*, client: <HOST>
+ mdre-fallback = ^\s*(?:(?!\[)\S+ nginx\[\d+\]: [^\[]*)?\[crit\] \d+#\d+: \*\d+ SSL_do_handshake\(\) failed \(SSL: error:\S+(?: \S+){1,3} too (?:long|short)\)[^,]*, client: <HOST>

(part (?:(?!\[)\S+ nginx\[\d+\]: [^\[]*)? would optionally match systemd prefix with also optional additional timestamp)

from fail2ban.

PanCakeConnaisseur avatar PanCakeConnaisseur commented on June 16, 2024

Thanks a lot for the quick resolution. I suspected that my workaround is a dirty hack.

from fail2ban.

Owned67 avatar Owned67 commented on June 16, 2024
mdre-fallback = ^\s*(?:(?!\[)\S+ nginx\[\d+\]: [^\[]*)?\[crit\] \d+#\d+: \*\d+ SSL_do_handshake\(\) failed \(SSL: error:\S+(?: \S+){1,3} too (?:long|short)\)[^,]*, client: <HOST>

Ive apply but always same it return 228 missed... any suggestion?

Debian 11
Fail2ban 0.11.2

from fail2ban.

sebres avatar sebres commented on June 16, 2024

People... nobody can provide any suggestions, if you give zero info.
In order to help you, we need at least one "missed" message you complain about...
Try it with:

fail2ban-regex --print-all-missed systemd-journal 'nginx-http-auth[mode=aggressive]'

and provide few lines that are still missed by filter as an example.

from fail2ban.

Owned67 avatar Owned67 commented on June 16, 2024

f2b.txt

from fail2ban.

sebres avatar sebres commented on June 16, 2024

It doesn't look to me that your nginx writes the error-log to systemd journal - there is no one message which should be matched by filter. I see only warnings or start emergency-messages (throwed by start of nginx-unit per worker), nothing else.

If you mean it must be really systemd journal, try to find out (with journalctl in json output) which tags it uses exactly, current filter use _SYSTEMD_UNIT=nginx.service + _COMM=nginx.
For instance:

journalctl -o json | grep nginx

(or something similar)

If not (errorlog is a file) - you must use backend = auto and set proper logpath for this jail.

from fail2ban.

Owned67 avatar Owned67 commented on June 16, 2024

ok ok will check later, too many result with journalctl -o json | grep nginx... no time for check all now xD

Thanks for helped me!

from fail2ban.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.