Nextcloud Fail2Ban Configuration for Email

If you are planning on using Fail2Ban and wish to receive emails on any failed attempts to access your Nextcloud server. Just add the following lines to your nextcloud.local:

action_mw = %(action_)s
%(mta)s-whois[sender=ā€œ%(sender)sā€, dest=ā€œ%(destemail)sā€, protocol=ā€œ%(protocol)sā€, chain=ā€œ%(chain)sā€]
action = %(action_mwl)s

Your final configuration should look like this.

[nextcloud]
backend = auto
enabled = true
port = 80,443
protocol = tcp
filter = nextcloud
maxretry = 3
bantime = 86400
findtime = 43200
logpath = /var/www/nextcloud/data/nextcloud.log
action_mw = %(action_)s
%(mta)s-whois[sender=ā€œ%(sender)sā€, dest=ā€œ%(destemail)sā€, protocol=ā€œ%(protocol)sā€, chain=ā€œ%(chain)sā€]
action = %(action_mwl)s

1 Like