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