The NGINX HTTP Server
[ 132 ]Combining these different rate limitations enables us to create a configuration that
is very flexible as to how and where clients are limited:
http {limit_conn_zone $binary_remote_addr zone=ips:10m;limit_conn_zone $server_name zone=servers:10m;limit_req_zone $binary_remote_addr zone=requests:10m rate=1r/s;limit_conn_log_level notice;limit_req_log_level warn;reset_timedout_connection on;server {# these limits apply to the whole virtual server
limit_conn ips 10;
# only 1000 simultaneous connections to the same server_name
limit_conn servers 1000;location /search {# here we want only the /search URL to be rate-limited
limit_req zone=requests burst=3 nodelay;}location /downloads {# using limit_conn to ensure that each client is
# bandwidth-limited
# with no getting around it
limit_conn connections 1;limit_rate_after 1m;limit_rate 500k;}}}