I’m trying to use the crazy-max/docker-fail2ban
docker container to enforce fail2ban rules on my BitWarden container. Of note, my container is named bitwarden
, not bitwarden_rs
.
Relevant bits of my compose:
bitwarden:
container_name: bitwarden
hostname: bitwarden
image: bitwardenrs/server:latest
volumes:
- "/docker/config/bitwarden:/data"
- "/etc/localtime:/etc/localtime:ro"
environment:
- "LOG_FILE=/data/bitwarden.log"
- "WEBSOCKET_ENABLED=true"
- "TZ=America/New_York"
ports:
- "3012:3012"
restart: unless-stopped
labels:
- "com.ouroboros.enable=true"
logging:
driver: json-file
options:
max-file: "3"
max-size: "10M"
network_mode: BucketNet
fail2ban:
container_name: fail2ban
hostname: fail2ban
image: crazymax/fail2ban:latest
network_mode: "host"
cap_add:
- "NET_ADMIN"
- "NET_RAW"
volumes:
- "/docker/config/fail2ban:/data"
- "/var/log/auth.log:/var/log/auth.log:ro"
- "/docker/config/bitwarden/bitwarden.log:/var/log/bitwarden.log:ro"
- "/docker/config/nginx/var-log-nginx:/var/log/nginx:ro"
- "/etc/localtime:/etc/localtime:ro"
environment:
- "TZ=America/New_York"
restart: unless-stopped
labels:
- "com.ouroboros.enable=true"
logging:
driver: json-file
options:
max-file: "3"
max-size: "10M"
My action.d/iptables-common.local
:
[Init]
blocktype = DROP
[Init?family=inet6]
blocktype = DROP
My filter.d/bitwarden.local
:
[INCLUDES]
before = common.conf
[Definition]
failregex = ^.*Username or password is incorrect\. Try again\. IP: <ADDR>\. Username:.*$
ignoreregex =
My jail.d/bitwarden.local
:
[bitwarden]
enabled = true
port = 80,443,8081
filter = bitwarden
action = iptables-allports[name=bitwarden, chain=FORWARD]
logpath = /var/log/bitwarden.log
maxretry = 3
bantime = 14400
findtime = 14400
Of note, my BitWarden is not exposed directly at all, but reverse proxy’ed via Nginx. I have proper headers forwarded, and when I test and check my fail2ban logs I see messages with the correct IP and stating that it’s banning the IP, but nothing happens and I’m still able to access BitWarden.
Any ideas?