ngx_http_subrange_module就是为了解决这个问题，它能分割HTTP requests。将大数据量的HTTP请求切分为多个子请求，当下载一个1 G的文件,subrange将从后端主机中下载文件块，比如先获取5 M，然后再获取5 M,直到客户端下载完整个文件。
Split one big download file request to multiple subrange requests to avoid geting too much data from upstream at one time.
Configure nginx with
When nginx is used as a reverse proxy for file downloading service, it will always run out of the bandwidth between nginx and upstream when the user requests a very large file. This is because nginx fetch a whole file at a time and buffer the left data that the client can not read in time. The bandwidth would be used up and the disk iowait would be high.
Nginx has an option to turn off the buffer mechanism, for example set
The subrange module is created to solve this problem. It splits your HTTP requests. When you want to download an 1G file, the module will try to download a chunk of the file from the upstream, for example downloads 5M first, and then the next 5M, until the client receives the whole file. The whole process is non-sensible to client. You can set the chunk size in the nginx configuration file.
The module sets the HTTP Range header to perform a Range request to get a chunk from the upstream. So the supporting of Range request is needed by upstream. Supporting
We just have one directive