Nginx by default waits for session to be closed until it opens a new session. this is a problem if a user tries to download more than one archive at once.

How to disable or upper the limit?

what i've tried:

changing  rate=1r/s to rate=100r/s  
limit_req_zone  $binary_remote_addr  zone=one:10m   rate=1r/s;

nginx conf:

server {
    #limit_conn addr 3;
    #limit_rate_after 2048k;
    #limit_rate 300k;
    server_name  site.com;
    access_log off;
    #access_log  /var/log/nginx/site.com.access.log  main;
    error_log   /var/log/nginx/site.com.error.log  crit;
    #open_file_cache max=3000 inactive=120s;
    #open_file_cache_valid 30s;
    #open_file_cache_min_uses 2;
    #open_file_cache_errors off;
            location / {
                 valid_referers none blocked site.com *.site2.com site3.net *.prozerpina.net;
                 if ($invalid_referer) {
                    return   403;
                    root /var/www/site.com;
                            aio on;
                            directio  4k;
                            directio_alignment 4k;
                            output_buffers 1 1m;


http {
    access_log  /var/log/nginx/access.log  main;
    client_max_body_size 2005m;
    server_names_hash_bucket_size 64;
    client_body_temp_path /tmp;
    client_body_in_file_only clean;
#    limit_conn_zone $binary_remote_addr zone=addr:10m;
    send_timeout 30;
    keepalive_timeout 60;
    proxy_buffering off;
    tcp_nodelay    on;
    log_not_found on;
    tcp_nopush     off;
    sendfile off;
    reset_timedout_connection on;
    limit_req_zone  $binary_remote_addr  zone=one:10m   rate=1r/s;
    index  index.php  index.html;


Changing rate=1r/s to rate=100r/s should work, unless your client needs more than 100 requests per second to download 2 files. Normally downloading 2 files requires 2 connections.

However, to me using rate-limiting to limit the number of simultaneous connections is using the wrong tool. You have something called limit_conn which limits connections, not rates. It works the same way, as you can define the zone for client IP addresses. You then decide on the limit, which is a raw number.

Again, those are 2 different problems: connection rate and amount are not to be confused, though they might interfere with one another.

Try disabling rate-limiting and use connection-limiting with 2 connections per client. Ensure your client works properly.

Then, you may wish to reinstall rate-limiting, taking good care that it does not interfere with your client usage. You may want to allow bursts of connection if your rate limit is low. Use then logs against failed connections to know if either limit_conn or limit_req is hold responsible for it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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