标签:upload 前端 server class pre www log 限流 节点
/collections/upload_traffic_info.json接口
nginx.conf server节点
location ~ /collections/upload_traffic_info.json {
return 403;
}
nginx -s reload
之前cpu99%+的原因:
apache 前端没有限流 cpu 99%+
引入nginx,limit_req_zone做限流,cpu指标下降正常,nginx前置了cdn或代理,$binary_remote_addr,那么$binary_remote_addr的值就是CDN的IP地址,这样限流的话就不对了。需要获取到用户的真实IP进行限流
## 这里取得原始用户的IP地址
map $http_x_forwarded_for $clientRealIp {
"" $remote_addr;
~^(?P<firstAddr>[0-9\.]+),?.*$$firstAddr;
}
## 针对原始用户 IP 地址做限制
limit_req_zone $clientRealIp zone=one:10m rate=1r/s;
Nginx限流参考资料
Nginx使用limit_req_zone对同一IP访问进行限流
https://blog.csdn.net/keketrtr/article/details/75315330
https://www.cnblogs.com/niyueling/p/11572003.html
http://www.zzvips.com/article/46527.html
标签:upload 前端 server class pre www log 限流 节点
原文地址:https://www.cnblogs.com/hnhycnlc888/p/13053499.html