Skip to content

Fail2ban

rmfakecloud itself blocks an IP address for 15 minutes after 5 failed web UI logins. Behind a reverse proxy this needs RM_TRUST_PROXY=1, otherwise all clients share the proxy's address.

For a public server fail2ban adds some security by banning ip's after few (configurable) failed login attempts. Assuming rmfakecloud is running in docker via systemd and logs to the syslog (journalctl) and fail2ban is already installed and setup. Instructions install and setup fail2ban in the documentation of the used operating system or at https://github.com/fail2ban/fail2ban#installation . rmfakecloud needs to trust the reverse proxy in use, i.e. add RM_TRUST_PROXY=1 (proxy on loopback or a private network) or the proxy's IP to the docker environment, see configuration.

Jail

First it is necessary to define a jail, e.g. in /etc/fail2ban/jail.local:

[rmfakecloud]
enabled   = true
filter   = rmfakecloud
action   = iptables-multiport[name=HTTP, port="http,https"]
journalmatch = _SYSTEMD_UNIT=docker-rmfakecloud.service

where it is necessary to change "docker-rmfakecloud.service" to the name of the systemd service used to run the server and the ban action appropriate to the setup of the host.

Filter

Additionally the filter

[Definition]
failregex = ^.*, login failed ip:\s+<ADDR>.*$

in /etc/fail2ban/filter.d/rmfakecloud.conf tells fail2ban which lines are relevant. Wrong passwords and wrong two-factor codes both match it.

After creating the necessary configuration, restarting fail2ban loads the changes.