mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-08 16:49:02 +03:00
[GH-ISSUE #293] Add unauthorized logging to stdout #154
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vuhuy on GitHub (Nov 24, 2023).
Original GitHub issue: https://github.com/sigoden/dufs/issues/293
Specific Demand
It would be nice to see failed basic authentication in the logging. That way, we can use third-party tools like fail2ban to block bots and unwanted visitors. These tools need the client IP address, and perhaps we need to accommodate some reverse proxy setups too.
Thanks for this lightweight project!
Implement Suggestion
This is my quick and dirty implementation to test my setup. I'm pretty sure my coding standard wouldn't meet the quality of this project, I never programmed in rust before, don't even have a compiler and just abused GitHub Actions and notepad to test this. But it might give you an exact idea of what I'm trying to achieve here.
Hacky addition to server.rs
auth.rsinstead.X-Real-IPheader due to reverse proxy. Should probably look at this header first, if not present, usesession.remote_addr().Systemd example service file
Fail2ban example filter
Fail2ban example jail
Nginx reverse proxy configuration snippet
@sigoden commented on GitHub (Nov 25, 2023):
You can achieve your goals by configuring log-format. @vuhuy
Run dufs with
dufs --log-format '$http_x_real_ip "$request" $status'. You will get what you want.To learn how to config log-format, please see readme.
Log sample:
Fail2ban example filter
@vuhuy commented on GitHub (Nov 25, 2023):
Ah, sorry for wasting your time. I totally missed the 401 in the logging. Thank you!
@sigoden commented on GitHub (Nov 25, 2023):
I don't mind, I'm happy if someone likes dufs.
Note: the default log-format is
'$remote_addr "$request" $status'. In your case, it is appropriate to use$http_real_ipor$http_x_forwarded_forinstead of$remote_addr.