Nginx limits the number of concurrent ip addresses, that is, limits the number of simultaneous connections from the same ip address to the server. add the limit_zone variable to use vi/usr/local/nginx/conf/nginx only in http. conflimit_zoneone $ remote_addr10m; 2. you can add the limit_conn variable in http, server, and loca.
Nginx limits the number of concurrent ip addresses, that is, limits the number of simultaneous connections from the same ip address to the server.
1. add limit_zone
This variable can only be used in http
Vi/usr/local/nginx/conf/nginx. conf
Limit_zone one $ remote_addr 10 m;
2. add limit_conn
This variable can be used in http, server, and location.
I only restrict one site, so add it to the server
Vi/usr/local/nginx/conf/host/gaojinbo.com. conf
Limit_conn one 10;
3. restart nginx
Killall-HUP nginx
Nginx speed limit module
Refer:
About limit_zone: http://wiki.nginx.org/NginxHttpLimitZoneModule
About limit_rate and limit_conn: http://wiki.nginx.org/NginxHttpCoreModule
Nginx can use HTTPLimitZoneModule and HTTPCoreModule to speed up directories.
Http {
Limit_zone one $ binary_remote_addr 10 m;
Server {
Location/download /{
Limit_conn one 1;
Limit_rate 300 k;
}
}
}
Limit_zone is a container that defines the session state for each IP address. In this example, a 10 m container is defined. according To 32 bytes/session, 320000 sessions can be processed.
Limit_conn one 1;
Each IP address can only initiate one concurrent connection.
Limit_rate 300 k;
The speed limit for each connection is 300 k. Note that the speed limit for the connection is here, not for the IP address. If an IP allows two concurrent connections, the IP address is limited to limit_rate × 2.