In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces Nginx how to achieve the current limit configuration of the number of connections to ip in the network segment, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
The so-called connection limit in Nginx is actually a tcp connection, that is, the connection status successfully established by the requester through a three-way handshake. Nginx generally provides us with ngx_http_limit_conn_module modules to provide limited connection capabilities. The module can limit the number of connections per key value according to the defined keys, just like the number of connections from an IP source.
Ngx_http_limit_conn_module instruction interpretation
Syntax: limit_conn zone number;Default:-Context: http, server, location
This directive describes the session state storage area. The current number of connections is saved in the state of the key, and the value of the key can be any non-null value of a particular variable (null values will not be considered). The variable definition key, and the zone=name definition region name. Common examples of use:
Limit_conn_zone $binary_remote_addr zone=addr:10m;server {location / download/ {limit_conn addr 1;}
The above example shows that when you request to access / download/, only one request connection at a time will successfully download the resource.
Network segment limit
Common limit_conn_zone configurations generally set $binary_remote_addr or $server_name to limit the number of connections at a single ip or host level.
But sometimes we want to limit the number of connections to a certain ip segment, so we can do this:
Http {...... Limit_conn_zone $ip_segment zone=network_segment:10m; server {. Set $ip_segment $remote_addr; if ($ip_segment ~ ^ (\ d +)\. (\ d +) {set $ip_segment $1. Limit_conn network_segment. 2. 3;} location / download/ {limit_conn network_segment 10; # limit_rate 200k;}
This can basically meet the Nginx limit on the number of connections of all ip in the network segment.
Thank you for reading this article carefully. I hope the article "how to achieve the current limit configuration of the number of connections to ip in the network segment" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.