Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 need to detect bots that act as authenticated users and saturate database's available connections by sending repetitive requests. I am wondering whether it is possible to stop dummy them using nginx directives?

The idea is that set up some rules in nginx configuartion so that IPS that connect more than certain numbers in a time frame (say 30 times per minute) be automatically denied.

share|improve this question
up vote 2 down vote accepted

There's a module for that! The HttpLimitReqModule. The module documentation has a decent example that's enough to get you started. There are some pretty serious limitations with IP-based rate limiting though -- CGN and some sorts of forced proxies make multiple users come from the same IP address, and other sorts of forced proxies make one user come from multiple IP addresses. Then you've got the fun and games of rate-limiting across a load-balanced cluster... but if you're happy to deal with those tradeoffs, the nginx module does do exactly what it says on the tin.

share|improve this answer

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.