diff --git a/services/photoprism.nix b/services/photoprism.nix index 30d38e2..bd413bb 100644 --- a/services/photoprism.nix +++ b/services/photoprism.nix @@ -76,6 +76,7 @@ in { proxy_read_timeout 600; proxy_send_timeout 600; client_max_body_size 100m; + access_log /var/log/nginx/photoprism_access.log; ''; }; }; @@ -90,5 +91,23 @@ in { "${cfg.home}/storage" ]; }; + + services.fail2ban.jails = { + photoprism = '' + enabled = true + filter = photoprism-failed-login + port = http,https + maxretry = 3 + logpath = /var/log/nginx/photoprism_access.log + ''; + }; + + environment.etc = { + "fail2ban/filter.d/photoprism-failed-login.conf".text = '' + [Definition] + failregex = ^ -.*"POST \/api\/v1\/session HTTP[^"]*" 400 .*$ + ignoreregex = + ''; + }; }; }