Nginx how to disable multithread downloads

I was wondering if its possible to disable multithread downloads on nginx. Right now users can use download managers to download a file by splitting a file and I was wondering how I can prevent that on my nginx server.


Use the nginx example for the limit_conn configuration:

limit_zone one $binary_remote_addr 10m;

server {
  location /download/ {
    limit_conn one 1;
  }
}

It's not just download managers with Range requests that multiplex downloads (and this does not disable Range headers); modern browsers loading pages multiplex requests as well. Be very careful about using this configuration anywhere expect a location that you need to specifically prevent multiplexed downloads for.


The settings you are looking for were added in NGINX 1.1.12

proxy_cache_lock on; proxy_cache_lock_timeout 60;

When the first request for each file is made (and being copies to the proxy_temp_path) it is locked, and if a second request comes in, rather than starting a second request to the backend, the client waits proxy_cache_lock_timeout for the original request to finish. If the original request finishes before the timeout, the result from the first request (client A) is returned to client B. If the timeout expires, nginx starts a second request to the backend on behalf of client B

This is a better solution than 'limit_conn one 1' which restricts to a single concurrent request for the entire location, rather than per URI.