标签:stream keepalive 主机 time rem 大小 file default add
一、限制单个 IP 的并发连接数
[root@localhost ~]# cat /usr/local/nginx/conf/nginx.conf
.... http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; limit_conn_zone $binary_remote_addr zone=addr:10m; # 用于设置共享内存区域,addr 是共享内存区域的名称,10m 表示共享内存区域的大小 server { listen 80; server_name www.abc.com; location / { root html/www; index index.html index.htm; limit_conn addr 1; # 限制单个IP的并发连接数为1 } } }
二、限制虚拟主机总连接数
.... http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; limit_conn_zone $server_name zone=perserver:10m; server { listen 80; server_name www.abc.com; location / { root html/www; index index.html index.htm; limit_conn perserver 2; # 设置虚拟主机连接数为2 } } }
标签:stream keepalive 主机 time rem 大小 file default add
原文地址:http://www.cnblogs.com/pzk7788/p/6925805.html