How to control the total requests in Ngnix

Francis Daly francis at daoine.org
Thu Nov 30 10:17:07 UTC 2017


On Thu, Nov 30, 2017 at 05:12:18PM +0800, tongshushan at migu.cn wrote:

Hi there,

> I want to use ngnix to protect my system,to allow max 2000 requests sent to my service(http location).
> The below configs are only for per client ip,not for the total requests control.

> ##########method 1##########
> 
> limit_conn_zone $binary_remote_addr zone=addr:10m;

http://nginx.org/r/limit_conn_zone

If "key" is "$binary_remote_addr", it will be the same for the same
client ip, and different for different client ips; the limits apply to
each individual value of client ip (strictly: to each individual value of
"key").

If "key" is (for example) "fixed", it will be the same for every
connection, and so the limits will apply for all connections.

Note: that limits concurrent connections, not requests.

> ##########method 2##########
> 
> limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;

http://nginx.org/r/limit_req_zone

Again, set "key" to something that is the same for all requests, and
the limit will apply to all requests.

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list