Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there something that I can use to set rules for Apache to throttle temporarily or ignore any IP address that makes X number of requests per second?

It would be great if there is an Apache module for this. I had a look at mod_bandwidth and mod_limitipconn but it seems they base things on bandwidth which is very hard for me to determine bandwidth in terms of number of requests per IP.

I would be happy to use something external to Apache that will work on a standard Linux server (Fedora or CentOS).

share|improve this question

1 Answer 1

up vote 2 down vote accepted

iptables has rate- and connection-limiting modules available:

iptables -I INPUT -m limit --limit X/second -p tcp --dport 80 --syn -j ACCEPT

Note that this won't actually limit the number of HTTP requests; it'll limit the number of TCP connections, which might not correspond to the number of HTTP requests if the browser is using keepalive. Also note that most browsers will make a large number of parallel connections; you might want to use the --limit-burst option to make sure users don't get blocked by this behaviour.

share|improve this answer

Your Answer

 
discard

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.