[solved] 1024 MB limitation on static files download

Hi there,

I am having a difficult problem to solve on the site of one of my clients. He sells .ZIP files of varying sizes in his woocommerce shop.

When the size of the files exceeds 1024 Mb, as soon as the loading reaches this limit the download of the file fails, whatever the browser used.

I searched the web looking for solutions, for example to add this to /etc/nginx/common/locations:

location /FILES {
    proxy_max_temp_file_size 0;
}

None of the solutions I’ve found worked. What I would like to do is remove this limitation in the folder containing the ZIP, allowing at least 20 GB…

Do you have any leads to share?

Best regards, Rico

CONFIGURATION BASICS

EasyEngine v3.7.4 nginx version: nginx/1.10.3 SSL + letsencrypt certificate

/etc/nginx/nginx.conf

user www-data;
worker_processes auto;
worker_rlimit_nofile 100000;
pid /run/nginx.pid;

events {
        worker_connections 4096;
#        accept_mutex off;
        multi_accept on;
}

http {
        ##
        # EasyEngine Settings
        ##
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 30;
        types_hash_max_size 2048;

        server_tokens off;
        reset_timedout_connection on;
        add_header X-Powered-By "EasyEngine 3.7.4";
        add_header rt-Fastcgi-Cache $upstream_cache_status;

        # Limit Request
        limit_req_status 403;
        limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

        # Proxy Settings
        # set_real_ip_from      proxy-server-ip;
        # real_ip_header        X-Forwarded-For;

        fastcgi_read_timeout 300;
        client_max_body_size 100m;

        ##
        # SSL Settings
        ##

        ssl_session_cache shared:SSL:20m;
        ssl_session_timeout 10m;
        ssl_prefer_server_ciphers on;
        #ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
        ssl_ciphers HIGH:!aNULL:!MD5:!kEDH;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        ##
        # Basic Settings
        ##
        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        # Log format Settings
        log_format rt_cache '$remote_addr $upstream_response_time $upstream_cache_status [$time_local] '
        '$http_host "$request" $status $body_bytes_sent '
        '"$http_referer" "$http_user_agent"';

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k;
        gzip_http_version 1.1;
        gzip_types
            application/atom+xml
            application/javascript
            application/json
            application/rss+xml
            application/vnd.ms-fontobject
            application/x-font-ttf
            application/x-web-app-manifest+json
            application/xhtml+xml
            application/xml
            font/opentype
            image/svg+xml
            image/x-icon
            text/css
            text/plain
            text/x-component
            text/xml
            font/opentype
            image/svg+xml
            image/x-icon
            text/css
            text/plain
            text/x-component
            text/xml
            text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

Hi there, no idea? The problem is still not solved.

Cheers, RdH

Hi, Thanks for the link, but I have already spent time on a similar google search. I have tested dozens of proposed solutions, but none have worked so far. Best regards, RdH

Your issue is probably related to php configuration, not to nginx conf. Make sure to edit the lines in /etc/php/7.0/fpm/php.ini with the following values :

max_execution_time = 3000
memory_limit = 4096M
post_max_size = 4096M

Then use :

service php7.0-fpm restart

Hi,

thank you virtubox for this proposal, but it did not work, the downloads always provokes a network error after 1024 mb of loading. An other idea ?

Best regards, RdH

So edit the line client_max_body with the following value in nginx.conf

client_max_body_size 2G ;

Hi,

I made the change and restarted nginx, but the problem remains…

Best regards, rdh

Hi,

The problem is now solved. This came from the woocommerce configuration set to “force download”. By setting “X-Accel-Redirect / X-Sendfile” and editing the file /etc/nginx/common/locations like this, download of large files is now possible:

location /protected/ {
 internal;
 root/some/path;
}

Thank you in any case for the proposed solutions.

Best regards, rdh

You’ve probably already considered it, but wouldn’t your client be better off offloading downloads that big to Amazon S3 anyway? Woocommerce has a plugin for it.

Can you please explain it more? I couldn’t find the locations config file at the specified location. Is this file different from the file where you tried setting proxy_max_temp_file_size?