# How to setup Fail2Ban on Nextcloud where is running behind a apache2 reverse proxy?

**URL:** <https://help.nextcloud.com/t/how-to-setup-fail2ban-on-nextcloud-where-is-running-behind-a-apache2-reverse-proxy/146342>\
**Category:** ℹ️ Support\
**Tags:** reverseproxy, security, fail2ban, apache\
**Created:** [September 27, 2022, 6:25pm UTC](https://help.nextcloud.com/t/how-to-setup-fail2ban-on-nextcloud-where-is-running-behind-a-apache2-reverse-proxy/146342 "2022-09-27T18:25:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gillesouv1](https://help.nextcloud.com/user_avatar/help.nextcloud.com/gillesouv1/32/46164_2.png) [@gillesouv1](https://help.nextcloud.com/u/gillesouv1)\
**Post date:** [September 27, 2022, 6:25pm UTC](https://help.nextcloud.com/t/how-to-setup-fail2ban-on-nextcloud-where-is-running-behind-a-apache2-reverse-proxy/146342/1 "2022-09-27T18:25:52Z")

</div>

Hello,

I would like to install fail2ban for my Nextcloud. However, I found out that in my case you have to install fail2ban on my apache2 reverse proxy server. When I did that it did not work. I have created a log file with the necessary permissions. Created a filter.d/nextcloud.conf with:

```auto
[Definition]
failregex=^{"reqId":".*","remoteAddr":".*","app":"core","message":"Login failed: '.*' \(Remote IP: '<HOST>'\)","level":2,"time":".*"}$
          ^{"reqId":".*","level":2,"time":".*","remoteAddr":".*","user,:".*","app":"no app in context".*","method":".*","message":"Login failed: '.*' \(Remote IP: '<HOST>'\)".*}$
          ^{"reqId":".*","level":2,"time":".*","remoteAddr":".*","user":".*","app":".*","method":".*","url":".*","message":"Login failed: .* \(Remote IP: <HOST>\).*}$

```

and a jail.d/nextcloud.local

```auto
[nextcloud]
backend = auto
enabled = true
port = 80,443
protocol = tcp
filter = nextcloud
maxretry = 3
bantime = 36000
findtime = 36000
logpath = /var/log/nextcloud.log

```

However, this does not work. What can I do

---

<div class="post-metadata">

**Author:** ![devnull](https://help.nextcloud.com/user_avatar/help.nextcloud.com/devnull/32/27793_2.png) [@devnull](https://help.nextcloud.com/u/devnull)\
**Post date:** [September 28, 2022, 5:33am UTC](https://help.nextcloud.com/t/how-to-setup-fail2ban-on-nextcloud-where-is-running-behind-a-apache2-reverse-proxy/146342/2 "2022-09-28T05:33:59Z")

</div>

I think Nextcloud has got a lot of security and hardening options that personally i do not need **fail2ban**. But in [this documentation](https://docs.nextcloud.com/server/latest/admin_manual/installation/harden_server.html) you find also settings for fail2ban that differ from your settings. Maybe there is the problem.

Do you use **2FA**? I think the biggest risk for Nextcloud from the internet is user/password credentials and not to use 2FA and not heal the password problem. In contrast to this **fail2ban** only helps against senseless mass attacks, which are not to be expected with a private Nextcloud instance. If someone steals your password, fail2ban will be of no use at all.

---

<div class="post-metadata">

**Author:** ![wwe](https://help.nextcloud.com/user_avatar/help.nextcloud.com/wwe/32/72963_2.png) [@wwe](https://help.nextcloud.com/u/wwe)\
**Post date:** [December 13, 2024, 2:46pm UTC](https://help.nextcloud.com/t/how-to-setup-fail2ban-on-nextcloud-where-is-running-behind-a-apache2-reverse-proxy/146342/3 "2024-12-13T14:46:03Z")

</div>


