Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.