Csuper Blog

Csuper Blog

nginx 的限制链接数新语法
2013-11-22

 

刚把nginx从1.0.15升级到了1.2.0。

更新完后检测了一下配置文件。

# /ooo/nginx/sbin/nginx -t
nginx: [warn] the "limit_zone" directive is deprecated, use the "limit_conn_zone" directive instead in /ooo/nginx/conf/nginx.conf:38
nginx: the configuration file /ooo/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /ooo/nginx/conf/nginx.conf test is successful

出来了一个警告,limit_zone 已经弃用!该属性改成了limit_conn_zone。

查了一下,文档中有一句:

When several limit_conn directives are specified, any configured limit will apply. For example, the following configuration will limit the number of connections to the server per client IP and at the same time will limit the total number of connections to the virtual host:

 


nginx.conf端
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
..

 

虚拟主机配置端


server {
    ...
    limit_conn perip 10;
    limit_conn perserver 100;
}

 

 

发表评论: