Detailed description of Nginx access Speed limit configuration method

Source: Internet
Author: User

The development test stage in the local speed limit simulation public network environment, convenient debugging. Operational requirements include limiting the lower attachment speed, limiting each user's access speed, and limiting the speed of each IP link.

Simple configuration, just 3 lines, open the "Nginx root directory/conf/nginx.conf" configuration file modified as follows:

The code is as follows Copy Code
 http{   
 
     ...   
 
     Limit_ Zone one $binary _remote_addr 10m;  
 
     ...   
 
     server {  
 
         Location/{  
 
             ...   
 
            limit_conn one 2;   
 
             limit_rate 40k;  
 
        }  
 
    }  
 
 }

The above configuration explains: Limit_zone defines a container for each IP that stores the session state. This example defines a 10m size container named one, which is used in the limit_conn. LIMIT_CONN specifies that each visitor can only establish two links, limit_rate limit the speed of each link to no more than 40K. Therefore, the above configuration restricts user access to this site with a total speed limit of 80K.

Property Description Limit_zone

Syntax: Limit_zone zone_name $variable memory_max_size

Scope: http

Limit_conn

Syntax: Limit_conn zone_name allow each client to establish the number of links

Scope: HTTP, server, location

Limit_rate

Syntax: Limit_rate The maximum rate per link

Scope: HTTP, server, location

Detailed description of Nginx access Speed limit configuration method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.