Nginx使用limit_req_zone对同一IP访问进行限流
先在nginx.conf中的http模块下配置
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
区域名称one(自定义),占用空间大小为10m,平均处理请求速度不能超过每秒一次
在http模块的子模块server下配置
location ~* .htm$ {
limit_req zone=one burst=5 nodelay;
proxy_pass http://backend_tomcat;
}
burst 缓冲队列的长度
nodelay 不延迟
真正对限流起作用的就是rate=1r/s和burst=5这2个配置