I was hoping Discourse could log invalid login attempts to file, even if it is something you have to configure to do so. Then I could create a custom filter and jail for discourse
I use a centralized fail2ban server. the way it works is all my Containers, Docker images, VMs have a custom ban action:
in fail2ban you specify the action to take in your jail, such as: action = iptables-allports
then all you have to do is edit that action: sudo nano /etc/fail2ban/action.d/iptables-allports.conf
With this setup your container/docker/vm will fail2ban them locally, but it will also relay this information to your central fail2ban server. The central server can also take all collected IPs and make them available as txt banlist such as: https://fail2ban.YourDomain.com/banned.txt
Then you can have your pfsense firewall subscribe to this banlist, and you can even share the list with other pfsense routers. This way if they try breaking in on one application, they get banned from everything. This has worked great for me for years.
And all that I need to implement this for discourse is for discourse to write an entry to a log file when there is an invalid login attempt
The NGINX logs
Occasionally NGINX logs may contain some extra tips, they are located at:
cd /var/discourse
./launcher enter app
cd /var/log/nginx
The files access.log and error.log will be there as well as a bunch of rotated compressed files. Running less access.log.2.gz will automatically decompress and display the logfile for you.
This directory is also available on the host at /var/discourse/shared/standalone/log/var-log/nginx .
Unfortunately, the nginx error.log and access.log files do not log any invalid login attempts.
أهلاً @Falco شكراً على الرد. لقد تفقدت السجلات على الفور الآن، ومحاولة كلمة مرور صحيحة ومحاولة كلمة مرور غير صحيحة تبدوان متشابهتين بالنسبة لي (استجابة 200):
(لقد قمت بتنقية عنوان IP والنطاق، والباقي لم يمسه أحد)
رائع، شكراً على الرد! حالما أحصل على القليل من وقت الفراغ سأحاول إنشاء إضافة لتوليد هذه المعلومات! (كل ما أحتاجه هو تسجيل عنوان IP في ملف عندما يحاول شخص ما تسجيل الدخول بكلمة مرور غير صحيحة، على سبيل المثال: محاولة تسجيل دخول غير صالحة من IP 10.111.222.33)
أنا أكتب عن أدوار مسؤول الويب العصامي والمستخدم النهائي البحت، ولكن…
تسجيل الدخول غير صالح هو الخطأ 200 بحكم تعريفه. بالتأكيد، يمكن وينبغي أن يكون خطأ داخليًا للتطبيق، وفي مرحلة ما يولد شيئًا آخر، مثل الخطأ 403 بالإضافة إلى شيء آخر مثل إرسال رابط استرداد، ولكن لا ينبغي أو لا يمكن أن يحدث ذلك على الفور.
Fail2ban أداة لطيفة ولكنها مبالغ فيها حقًا. دعنا ننسى docker، لأنه يجعل كل شيء أصعب، ولكن مجرد حقيقة أنه يمكنه تجاوز iptables الخاص بـ VPS هو أمر ضبابي حقًا بالنسبة لي. لكن الروبوتات تميل إلى تغيير عنوان IP بعد كل محاولة ثالثة وهذا يجعل Fail2ban عديم الفائدة تمامًا ضد هجوم القوة الغاشمة عبر تسجيل الدخول.
المتسللون المبتدئون قصة أخرى، بالطبع. ينسخون ويلصقون كل ما يجدونه، ويقومون بتدويرها ولا يلعبون بعناوين IP. عندها يمكن لـ Fail2ban إيقافهم، حتى لو كانوا نادرًا ما يفعلون أي ضرر، ولكنهم يزيدون الحمل. المشكلة الحقيقية هي كمية المتسللين المبتدئين عندما يكون هناك تدفق فوري.
ولكن طالما أن VPS يمكنه التعامل مع مثل هذا الموقف، فهذا لا يهم. الآن هو عام 2023 ومعظم هؤلاء الأوغاد يطرقون الثغرات القديمة لـ wordpress على موقع discourse
ولكن يجب أن يكون لدينا بعض المنطق لإيقاف تسجيلات الدخول المستمرة، بغض النظر عما إذا كان هذا ليس تهديدًا يوميًا، على ما أعتقد.