http{
limit_conn_zone $binary_remote_addr zone=conn_zone:1m;
server {
listen 80;
server_name localhost;
location / {
root /usr/code;
limit_conn conn_zone 1;
index index.html index.htm;
}
}
然后
nginx -t -c /etc/nginx/nginx.conf
nginx -s reload -c /etc/nginx/nginx.conf
在另一台机器上使用
ab -n 30 -c 30 http://192.168.0.10/1.html
或者
ab -n 30 -c 30 -k http://192.168.0.10/1.html
结果是一样的,并没有对连接数进行限制,全部都是成功的,错误日志中也没有体现conn_zone生效。
Concurrency Level: 30
Time taken for tests: 0.013 seconds
Complete requests: 30
Failed requests: 0
Write errors: 0
老哥,解决了吗