Fail2ban
PLANKA already limits failed sign-ins on its own (see Sign-in Limits). Fail2ban adds to that by blocking an offending address at the firewall, based on PLANKA's log file.
Requirements
- The log file has to be reachable from the host. In a manual installation it is at
/var/www/planka/logs/planka.log; with Docker, you have to mount it. - Behind a reverse proxy, set
TRUST_PROXY=true. Otherwise, every failed sign-in is logged with the address of the proxy, and Fail2ban locks everybody out by banning it.
Setup
-
Create the Filter
Create
/etc/fail2ban/filter.d/planka.conf:[Definition]failregex = ^(.*) Invalid (email or username:|password!) (\"(.*)\"!)? ?\(IP: <ADDR>\)$^(.*) Login rate limit hit \(IP: <ADDR>\)$ignoreregex = -
Create the Jail
Create
/etc/fail2ban/jail.d/planka.local:[planka]enabled = truebackend = pollingport = http,httpsfilter = plankalogpath = /var/www/planka/logs/planka.logmaxretry = 5bantime = 900Adjust
logpathandportto your setup.maxretryis the number of failed attempts before an address is banned,bantimeis how long the ban lasts in seconds.warningAre you publishing PLANKA's port directly from Docker, with no reverse proxy on the host? Then add
chain = DOCKER-USERto the jail. Docker's forwarded traffic bypasses the defaultINPUTchain, so the ban would have no effect. -
Test the Filter and Restart Fail2ban
sudo fail2ban-regex /var/www/planka/logs/planka.log /etc/fail2ban/filter.d/planka.confsudo systemctl restart fail2ban -
Check the Jail
sudo fail2ban-client status planka