Nginx Limit user Download file rate

Source: Internet
Author: User

Download the Www.linuxom.com/download/movie.avi file, which is ready to download by default

# time wget Http://42.51.137.195/download/movie.avi--2013-04-05 02:42:39--Http://42.51.137.195/download/movie.avi Connecting 42.51.137.195:80 ...  is connected. An HTTP request has been made and is waiting for a response ... $ OK Length: 40817431 (39M) [Video/x-msvideo] is saving to: "MOVIE.AVI.1" 100%[======================================>] 40,81    7,431 116m/s in 0.3s 2013-04-05 02:42:40 (up to MB/s)-Saved "MOVIE.AVI.1" [40817431/40817431]) Real 0m0.342s user 0m0.021s SYS 0m0.180s

Modify the nginx.conf file to limit the download speed to 128kb/s

location/download {limit_rate 128k; }

Reload the configuration file

/usr/local/nginx/sbin/nginx-s Reload

Download the Www.linuxom.com/download/movie.avi file again

# time wget Http://42.51.137.195/download/movie.avi--2013-04-05 02:51:28--Http://42.51.137.195/download/movie.avi Connecting 42.51.137.195:80 ...  is connected. An HTTP request has been made and is waiting for a response ... $ OK Length: 40817431 (39M) [Video/x-msvideo] is saving to: "MOVIE.AVI.5" 3% [===>] 1,572, 864 526k/s ######################## #省略部分内容 ####################### #real 0m1.332suser 0m0.009ssys 0m0.0 11s

The speed limit was found to be successful.

If you want to set the user to download the first 10m size of the file is not limited to speed, greater than 10m and then 128kb/s speed limit can add the following content, modify the nginx.conf file

location/download {Limit_rate_after 10m;  Limit_rate 128k; }

Reload the configuration file

/usr/local/nginx/sbin/nginx-s Reload

Download the Www.linuxom.com/download/movie.avi file again

# time wget Http://42.51.137.195/download/movie.avi--2013-04-05 02:55:33--Http://42.51.137.195/download/movie.avi Connecting 42.51.137.195:80 ...  is connected. An HTTP request has been made and is waiting for a response ...  $ OK Length: 40817431 (39M) [Video/x-msvideo] saving to: "MOVIE.AVI.8" 26% [=================================>] 11,026,432 9.62m/s ##################### #省略部分内容 ########################### real 0m57.149s user 0m0.013s sys 0m0.212 S

Found before about 10m, about 26% of the file, file download unlimited speed, and then start the speed limit.

Nginx Limit user Download file rate

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.