Summary of the limit speed limit module of Nginx reverse proxy front End
About the Ngx_http_limit_conn_module, Ngx_http_limit_req_module module, Echo (need to install a third-party module Ngx_http_echo_module), map (default installation Ngx_http_ Map_module), Geo (default installation
Ngx_http_geo_module) Instructions Please check the official documentation, which is not mentioned here.
There are four types of cases:
One, but CDN speed limit configuration
Second, over CDN speed limit Configuration
Three, no white list, but CDN.
Four, no white list of over CDN
Let's start by explaining a question:
The IP in Geo can be either a single or a network segment, as long as it complies with the CIDR standard.
The IP in the map must be a, because here he looks at a variable.
The white list IP of the CDN only needs the client IP on the line, CND does not need, the client IP has a line to write
But the CDN Whitelist IP can write a network segment
The key Point Limited is empty and does not travel at the speed limit. There is value, here white_ip is 1, walk speed limit.
You can see through the Echo module (both of which do not go CDN):
This is a speed limit, not a whitelist.
Http://123.11.11.11/echo
Http_x_forwarded_for:
remote_addr:59.12.13.14
FIRSTADDR:
clientrealip:59.12.13.14
White_ip:1
limited:59.12.13.14
This unlimited speed, added the whitelist
Http://123.11.11.11/echo
Http_x_forwarded_for:
remote_addr:114.11.183.6
FIRSTADDR:
clientrealip:114.11.183.6
white_ip:0
Limited
One, but CDN speed limit configuration
Nginx.conf inside the configuration
Geo $white _IP {
Default 1;
127.0.0.1 0;
59.12.13.14 0;
61.11.12.0/24 0;
......
}
Map $white _ip $limited {
1 $binary _remote_addr;
0 "";
}
Limit_conn_zone $limited zone=addr:10m;
Limit_req_zone $limited zone=one:10m rate=50r/s;
Limit_req_log_level info;
Limit_conn_log_level info;
Specific domain name vhosts configuration file inside the application
Location/{
Limit_req Zone=one burst=5 Nodelay;
Limit_conn addr 100;
Proxy_pass http://my_test_com;
}
Second, over CDN speed limit Configuration
Nginx.conf inside the configuration
Map $http _x_forwarded_for $clientRealIpnormal {
"" $remote _addr;
~^(? P<firstaddr>[0-9\.] +),?. *$ $firstAddr;
}
Map $http _http_cdn_src_ip $clientRealIp {
"" $clientRealIpnormal;
Default $http _http_cdn_src_ip;
}
Map $clientRealIp $white _ip {
Default 1;
127.0.0.1 0;
59.12.13.14 0;
......
}
Map $white _ip $limited {
1 $clientRealIp;
0 "";
}
Limit_conn_zone $limited zone=addr:10m;
Limit_req_zone $limited zone=one:10m rate=30r/s;
Limit_req_zone $limited zone=two:10m rate=20r/s;
Limit_req_log_level info;
Limit_conn_log_level info;
Specific domain name vhosts configuration file inside the application
Location/{
Limit_req zone=two burst=1 Nodelay;
Proxy_pass http://mynew_test_com;
}
Three, no white list, but CDN.
Nginx.conf inside the configuration
Limit_conn_zone $binary _remote_addr zone=addr:10m;
Limit_req_zone $binary _remote_addr zone=one:10m rate=50r/s;
Limit_req_log_level info;
Limit_conn_log_level info;
Specific domain name vhosts configuration file inside the application
Location/{
Limit_req Zone=one burst=5 Nodelay;
Limit_conn addr 100;
Proxy_pass http://my_test_com;
}
Four, no white list of over CDN
Nginx.conf inside the configuration
Map $http _x_forwarded_for $clientRealIp {
"" $remote _addr;
~^(? P<firstaddr>[0-9\.] +),?. *$ $firstAddr;
}
Limit_conn_zone $clientRealIp _addr zone=addr:10m;
Limit_req_zone $clientRealIp _addr zone=one:10m rate=50r/s;
Limit_req_log_level info;
Limit_conn_log_level info;
Specific domain name vhosts configuration file inside the application
Location/{
Limit_req Zone=one burst=5 Nodelay;
Limit_conn addr 100;
Proxy_pass http://my_test_com;
}
This article is from the "jerrymin" blog, make sure to keep this source http://jerrymin.blog.51cto.com/3002256/1669835
Summary of the limit speed limit module of Nginx reverse proxy front End