title: How can I limit connections to my web application per minute?
body: <p>I have tried to use nginx (http://nginx.org/) to limit the amount of requests per minute. For example my settings have been:</p>
  
  <pre><code>server{
  limit_req_zone $binary_remote_addr zone=pw:5m rate=20r/m; 
  }
  location{
  limit_req zone=pw nodelay;
  }
  </code></pre>
  
  <p>What I have found with Nginx is that even if I try 1 request per minute, I am allowed back in many times within that minute. Of course fast refreshing of a page will give me the limit page message which is a "503 Service Temporarily Unavailable" return code.</p>
  
  <p>I want to know what kind of settings can be applied to limit a request exactly to 20 requests a minute. I am not looking for flood protection only because Nginx provides this where if a page is constatnly refreshed for example it limits the user and lets them back in after some time with some delay (unless you apply a nodelay setting). </p>
  
  <p>If there is an alternative to Nginx other than HAProxy (because its quite slow). Also the setup I have on Nginx is acting as a reverse proxy to the real site.</p>