Hi there,
Recently Odoo has made a commit to improve the way failing logins are handled. Thanks to this commit it should be possible to configure and use fail2ban security very easily in V11. This fix was introduced at https://github.com/odoo/odoo/commit/86ffb549bf80b054f8bb5131c52d3e7757accb29
No matter what I try the Fail2ban does not seem to detect the logfile changes and does not invoke the auto ban functionalities. This is how I've configured fail2ban:
1. Install fail2ban:
sudo apt-get install fail2ban
2. Copy the default fail2ban file:
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
3. Add in the file:
[odoo-login]
enabled = true
port = http,https
bantime = 900 ; 15 min ban
maxretry = 4 ; if 4 attempts
findtime = 600 ; within 10 min
logpath = /var/log/odoo11/odoo11-server.log
4. Create a custom filter.d record:
nano /etc/fail2ban/filter.d/odoo-login.local
5. Add in the following content:
[Definition]
failregex = ^ \d+ INFO \S+ \S+ Login failed for db:\S+ login:\S+ from <HOST>
ignoreregex =
6. Reload fail2ban:
sudo fail2ban-client reload
However when I now make multiple failing logins within a minute nothing is being logged in /var/log/fail2ban.log.
The Odoo log contains new lines that show the failing logins and I do see the configuration is loaded and applied for fail2ban:
2018-05-29 09:08:18,601 fail2ban.actions [1048]: INFO Set banTime = 900 2018-05-29 09:08:18,605 fail2ban.filter [1048]: INFO Set maxRetry = 4 2018-05-29 09:08:18,605 fail2ban.filter [1048]: INFO Set jail log file encoding to UTF-8 2018-05-29 09:08:18,613 fail2ban.filter [1048]: INFO Added logfile = /var/log/odoo11/odoo11-server.log 2018-05-29 09:08:18,617 fail2ban.filter [1048]: INFO Set findtime = 600 2018-05-29 09:08:18,636 fail2ban.jail [1048]: INFO Jail 'sshd' started 2018-05-29 09:08:18,655 fail2ban.jail [1048]: INFO Jail 'odoo-login' started
Regards,
Yenthe