nginx 1.2.0限速

ZephyrXT 发布于 阅读:31

server {

limit_conn perip 10;
limit_conn perserver 100;
}
These directives are inherited from the previous level if and only if there are no limit_conn directives on the current level.

对应conf文件夹中的nginx.conf文件,将limit_conn替换为limit_conn_zone。使用于http
示例:
limit_conn_zone $binary_remote_addr zone=perip:10m;  #容器共使用10M的内存来对于IP传输开销

对应的虚拟主机文件,将原来的limit_conn one 替换为 limit_conn perip。使用于server
示例:
limit_conn perip 10;  # 每个IP使用10个连接。

——————示例——————

limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;

server {

location /down/ {
limit_conn perip 1;
limit_rate 250k;
}


}

参考:

nginx 新语法 limit_conn_zone 替换 limit_conn 用法
https://bbs.zephyrxt.com/thread-10627-1-1.html