Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a lot of vulnerability scans via HTTP requests (trying to get /password.txt, etc). Currently I use fail2ban to parse Nginx access log to count 404's and ban attacker ip addresses. I'm wondering if it possible to simply configure iptables to rate limit HTTP requests instead?

I tried something like this

iptables -I INPUT -p tcp --dport 2012 -i eth0 -m state --state NEW -m recent  --updat…e --seconds 60 --hitcount 5 -j REJECT --reject-with icmp-host-unreachable

but apparently it does not work as expected. My guess is that the malicious HTTP requests are piped through a single persistent connection so the above iptables rule is not triggered.

So my question is: is it possible to rate limit HTTP requests in iptables, or I should stick with fail2ban? Thanks!

share|improve this question
up vote 1 down vote accepted

The problem is HTTP 1.1. You'll have to configure your web server to downgrade the connection to 1.0 in order to kill keepalive if you want this to work.

share|improve this answer
Thanks for the answer! So it confirmed my original suspicion. Unfortunately it is not OK to downgrade to HTTP/1.0. For most users we need to support keep-alive to keep latency down :( – Rio Dec 3 '10 at 23:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.