limit_conn不生效
来源:2-25 Nginx的请求限制_请求限制配置原理
慕后端5535294
2020-01-08
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
…
limit_conn_zone $binary_remote_addr zone=conn_zone:1m;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name localhost1;
location /mystatus{
stub_status;
}
location / {
root /opt/app/code1;
#random_index on;
index index.html index.htm;
sub_filter 'imooc' 'IMOOC';
sub_filter_once off;
limit_conn conn_zone 3;
#limit_req zone=req_zone burst=3 nodelay;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
重启加载配置之后,ab压力测试 200次请求,10个并发
ab -n 200 -c 10 http://localhost/ 结果如下:
Concurrency Level: 10
Time taken for tests: 0.447 seconds
Complete requests: 200
Failed requests: 0
感觉limit_conn不生效,测试好几遍不知道为啥。
写回答
1回答
-
慕后端5535294
提问者
2020-01-08
已解决,中间加了一个proxy_pass 转到一个动态端口就可以出来效果,静态的root下的html文件看不出来效果
10
相似问题