Skip to content

filter.d/immich: add new filter and jail for Immich - #4281

Open
rafaelsoje wants to merge 1 commit into
fail2ban:masterfrom
rafaelsoje:add-immich-filter
Open

rafaelsoje wants to merge 1 commit into
fail2ban:masterfrom
rafaelsoje:add-immich-filter

Conversation

@rafaelsoje

Copy link
Copy Markdown
Contributor

Summary

Adds official filter and jail configuration for Immich photo and video management solution, supporting both reverse proxy access logs (Nginx, Traefik, Apache, Caddy) and direct application server logs (NestJS / Docker / systemd-journal).

Closes gh-4029

Details

  • config/filter.d/immich.conf:
    • Implements regex for reverse proxy access logs targeting failed authentication attempts (POST /api/auth/login) returning HTTP status code 401 Unauthorized.
    • Implements regex for direct Immich application server logs targeting failed login warnings from [Api:AuthService] and legacy [AuthService].
    • Captures source address via <ADDR> (IPv4 and IPv6) and username via <F-USER>.
    • Uses before = common.conf and %(__prefix_line)s to dynamically support standard file logging as well as systemd journal format (logtype = journal).
    • Configures journalmatch = _SYSTEMD_UNIT=immich-server.service + _COMM=immich-server.
  • config/jail.conf:
    • Added [immich] jail definition with ports http,https,2283 and default logpath /var/log/nginx/immich.access.
  • fail2ban/tests/files/logs/immich:
    • Regression test samples for reverse proxy logs (IPv4, IPv6, virtual host prefix).
    • Regression test samples for direct NestJS application logs (modern, legacy, IPv6).
    • Dedicated systemd-journal test samples (filterOptions: [{"logtype": "journal"}]) covering both IPv4 and IPv6.
    • Negative control cases (# failJSON: { "match": false }) for successful logins (201 Created) and non-auth 401 responses (e.g. /api/photos) to ensure no false positives.
  • ChangeLog:
    • Added entry under ### New Features and Enhancements.

Verification

  • fail2ban-regex tests:
    • Reverse proxy sample: Lines: 1 lines, 0 ignored, 1 matched, 0 missed
    • NestJS direct sample: Lines: 1 lines, 0 ignored, 1 matched, 0 missed
    • Systemd journal sample with [logtype=journal]: Lines: 1 lines, 0 ignored, 1 matched, 0 missed
  • Automated test suite:
    • ./bin/fail2ban-testcases samplestestcase -> Ran 103 tests in 0.541s, OK
    • ./bin/fail2ban-testcases clientreadertestcase -> OK (stock jail.conf consistency check passed)
    • ./bin/fail2ban-testcases -f -m -n -> Ran 530 tests in 5.257s, OK

Checklist

  • CONSIDER adding a unit test if your PR resolves an issue
  • LIST ISSUES this PR resolves or describe the approach in detail
  • MAKE SURE this PR doesn't break existing tests
  • KEEP PR small so it could be easily reviewed
  • AVOID making unnecessary stylistic changes in unrelated code
  • ACCOMPANY each new failregex for filter X with sample log lines (and # failJSON) within fail2ban/tests/files/logs/X file
  • PROVIDE ChangeLog entry describing the pull request

Add filter and jail configuration for Immich photo and video
management solution, supporting both reverse proxy access logs
and direct application server logs with respective unit test samples.

Closes fail2bangh-4029

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR]: Samba and Immich failregexs

1 participant