初学,Nginx的limit_conn_zone限制问题,请指教!

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
阅读 2.8k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进