Nginx speed limit,
Note:
The syntax for Versions later than nginx 1.1.8 is changed to limit_conn_zone $ binary_remote_addr zone = NAME: 10 m;
NAME is the NAME of the zone, please see here http://nginx.org/en/docs/http/ngx_http_limit_conn_module.html
Maximum number of connections:
To restrict connections, you must first have a container that counts connections and add the following code to the http segment:
"Zone =" give it a name, which can be called at will. The name must be consistent with the following limit_conn.
$ Binary_remote_addr = uses binary to store the client address. 1 m can store 32000 concurrent sessions.
... Saving N characters
Http
{
Limit_conn_zone $ binary_remote_addr zone = addr: 10 m;
Next, we need to limit the speed of different locations (location segments) of the server. For example, to limit the number of concurrent connections of each IP address to 1
Server
{
Listen 80;
Server_name 192.168.11.128;
Index index.html index.htm index. php;
Limit_conn addr 1; # restrict each IP address to initiate only one connection (addr must correspond to the variable of limit_conn_zone)
Limit_rate 100 k; # The speed limit is KB/second.
Root html;
Note:
Limit_rate 100 k; // The speed limit is 100 k for each connection. Here is the connection speed limit, not the IP speed limit! If an IP address allows two concurrent connections, the IP address is limited to 2.