Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx limits the number of visits and concurrency

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Nginx limit access rate and maximum number of concurrent connections module-limit (prevent DDOS)

Http:

# # zone=one or allips means to set a storage named "one" or "allips" with a size of 10 megabytes

# # rate=2r/s allows no more than 2 requests per second

Limit_conn_log_level error

Limit_conn_status 503

Limit_conn_zone $binary_remote_addr zone=one:10m

Limit_conn_zone $server_name zone=perserver:10m

Limit_req_zone $binary_remote_addr zone=allips:100m rate=2r/s

Server:

# # burst=5 means that the maximum number of delayed requests is not greater than 5. If too many requests are delayed and it is not necessary to use the nodelay parameter, the server will return the 503 status code immediately.

Limit_conn one 100; # # indicates the maximum number of concurrent connections

Limit_conn perserver 1000

Limit_req zone=allips burst=5 nodelay

Parameter explanation:

$binary_remote_addr restricts the same client ip address

$server_name limits the maximum number of concurrency of the same server

Limit_conn is to limit the number of concurrent connections

Limit_rate is to limit download speed.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report