nginx限流
geo $limit_ip { # geo用法参考:http://www.ttlsa.com/nginx/using-nginx-geo-method/
default 0;
10.145.170.0/24 1;
}
map $limit_ip $limit_ip_key {
0 "";
1 "key";
}
limit_req_zone $limit_ip_key zone=cus_limit_ip_zone1:10m rate=50r/s;
location /cus/cusbizassetcap/serviceIdListByAccountNO {
proxy_set_header Host cusgateway.cus.${upstreamenv}.com;
limit_req zone=cus_limit_ip_zone1 burst=10 nodelay;
limit_req_status 429;
proxy_pass http://k8s_traefik/cusbizassetcap/serviceIdListByAccountNO;
}
限流参考:https://mp.weixin.qq.com/s/MT8Z189DBnSuXGFVTKUSVQ
http {
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
server {
location /test/ {
limit_reqzone=mylimit burst=20;
proxy_passhttp://backend;
}
}
}
http {
limit_req_zone$binary_remote_addr zone=mylimit:10m rate=10r/s;
server {
location /test/ {
limit_reqzone=mylimit burst=20 nodelay;
proxy_passhttp://backend;
}
}
}