I've set up Fail2Ban on Amazon Linux 2, enabling the built-in nginx-http-auth
jail with this override config:
[nginx-http-auth]
enabled = true
action = iptables[name=HTTPS, port=https, protocol=tcp]
logpath = <snip>/logs/*error*.log
findtime = 15m
bantime = 15m
maxretry = 5
The action is triggering and I'm getting the following entry in iptables -S
:
-A f2b-HTTPS -s 120.<snip>.122/32 -j REJECT --reject-with icmp-port-unreachable
However, I can continue making new HTTPS requests from the banned IP which are receiving 401 responses from Nginx. I've replicated from two IP addresses - my phone and another EC2 host.
Here's the full output of iptables -L
:
(Note: Nginx is running inside Docker, as are two other containers that are isolated from the local network)
Chain INPUT (policy ACCEPT)
target prot opt source destination
f2b-HTTPS tcp -- anywhere anywhere tcp dpt:https
Chain FORWARD (policy DROP)
target prot opt source destination
DOCKER-USER all -- anywhere anywhere
DOCKER-ISOLATION-STAGE-1 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (2 references)
target prot opt source destination
ACCEPT tcp -- anywhere ip-192-168-208-2.ap-southeast-2.compute.internal tcp dpt:webcache
Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target prot opt source destination
DOCKER-ISOLATION-STAGE-2 all -- anywhere anywhere
DROP all -- !ip-192-168-192-0.ap-southeast-2.compute.internal/20 anywhere
DROP all -- anywhere !ip-192-168-192-0.ap-southeast-2.compute.internal/20
DROP all -- !ip-192-168-176-0.ap-southeast-2.compute.internal/20 anywhere
DROP all -- anywhere !ip-192-168-176-0.ap-southeast-2.compute.internal/20
DOCKER-ISOLATION-STAGE-2 all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-ISOLATION-STAGE-2 (2 references)
target prot opt source destination
DROP all -- anywhere anywhere
DROP all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-USER (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain f2b-HTTPS (1 references)
target prot opt source destination
REJECT all -- 120.<snip>.122 anywhere reject-with icmp-port-unreachable
RETURN all -- anywhere anywhere
Why isn't the iptable rule stopping HTTPS requests?
Do I need to change my fail2ban config somehow to make it work?