The development test stage in the local speed limit simulation public network environment, convenient debugging. Operational requirements include limiting the lower attachment speed, limiting each user's access speed, and limiting the speed of each IP link.
Simple configuration, just 3 lines, open the "Nginx root directory/conf/nginx.conf" configuration file modified as follows:
The code is as follows |
Copy Code |
http{ ... Limit_ Zone one $binary _remote_addr 10m; ... server { Location/{ ... limit_conn one 2; limit_rate 40k; } } } |
The above configuration explains: Limit_zone defines a container for each IP that stores the session state. This example defines a 10m size container named one, which is used in the limit_conn. LIMIT_CONN specifies that each visitor can only establish two links, limit_rate limit the speed of each link to no more than 40K. Therefore, the above configuration restricts user access to this site with a total speed limit of 80K.
Property Description Limit_zone
Syntax: Limit_zone zone_name $variable memory_max_size
Scope: http
Limit_conn
Syntax: Limit_conn zone_name allow each client to establish the number of links
Scope: HTTP, server, location
Limit_rate
Syntax: Limit_rate The maximum rate per link
Scope: HTTP, server, location
Detailed description of Nginx access Speed limit configuration method