Fail2Ban Integration
Summary
Fail2ban scans log files (e.g. /var/log/nginx/error.log) and bans IPs that show malicious signs -- too many password failures, seeking for exploits, etc. Generally Fail2Ban is then used to update firewall rules to reject the IP addresses for a specified amount of time, although any arbitrary other action (e.g. sending an email/notification) could also be configured.
Prerequisites
Fail2ban installed and configured
Fail2Ban filter
Go to your filter.d
folder in your Fail2Ban install location /etc/fail2ban/filter.d
and create a file called organizr-auth.conf
and add the following:
Organizr Jail
Edit the jail.local
file in the Fail2Ban directory and add the following:
The ignore IP is so that fail2ban won’t ban your local IP. Check out https://www.aelius.com/njh/subnet_sheet.html if you are wondering what your CIDR notation is. Most often it will be /24 (netmask 255.255.255.0)
To find your netmask run ipconfig /all
on windows or ifconfig | grep netmask
on linux.
Restart Fail2Ban with sudo service fail2ban restart
Organizr logs
Normal Install
Docker Install
Docker
Because the Organizr container only logs the docker IP addresses e.g 172.17.0.2
you need to add this in the Organizr default nginx site file. Go to \organizr\nginx\site-confs\default
and add the following inside the server block:
If you're using organizr/organizr
it's already added and you only need to uncomment the set_real_ip_from
line.
Then restart the container: docker restart organizr
Using the linuxserver/swag container
The Fail2ban filter folder is in /<appdatafolder>/swag/fail2ban/filter.d
For this to work you need the SWAG container to be able to read the organizr-<date>.log
file in the Organizr container.
Mount the Organizr log like this:
And set the log path in the Fail2Ban jail.local
file to /organizrlog/organizr*.log
Banned
The fail2ban.log
file should output something like this:
If you managed to ban yourself or a friend banned themself you can run one of these commands:
Thanks to rix1337 for the fail2ban config:
Last updated