Using Nginx with chunking

Arun John (arujohn) arujohn at
Wed Aug 12 09:30:15 UTC 2015


I have nginx configured to send files in chunks to remote clients. The clients will contact the server to send it in chunks of 1 MB each. I am using nginx version 1.8.0

[root at ph-rdu-external-download-01 sbin]# ./nginx -V

nginx version: nginx/1.8.0

built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)

built with OpenSSL 1.0.1e-fips 11 Feb 2013

TLS SNI support enabled

configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --lock-path=/var/lock/subsys/nginx --with-ld-opt=-Wl,-rpath,/usr/lib64 --with-debug --add-module=/root/integ/ngx_devel_kit-master/ --add-module=/root/integ/lua-nginx-module-0.9.15 --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --without-http_autoindex_module --without-http_fastcgi_module --with-http_ssl_module --without-http_geo_module --without-http_empty_gif_module --without-http_ssi_module --without-http_userid_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-ipv6

Currently I am running into an issue, where if the last chunk size is very small (few bytes), the server doesn’t seem to the send the chunk correctly because of which the clients would re-try again for the same chunk. For some reason it is not able to send the last chunk. I have attached the debug logs to the thread. If you see the logs the last three writes seem to be for the same chunk of size 6672 bytes

However if the last chunk size relatively large, then download succeeds without any issues. The issue is seen when the last chunk size is very small.

My current nginx configuration is as follows

http {

        # Logging format

        log_format main '$remote_addr - $remote_user [$time_local]  ' '"$request_length" "$request_time" '

    '"$request" $status $bytes_sent ' '"$body_bytes_sent" "$bytes_sent" ';

        default_type                    application/octet-stream;

        include                         mime.types;

        keepalive_timeout               300 300;

        keepalive_requests              8000;

        charset                         utf-8;

        source_charset                  utf-8;

        # Check if it makes errors.

        ignore_invalid_headers      off;

        recursive_error_pages           on;

        sendfile                        on;

        server_tokens                   off;

        tcp_nodelay                     on;

        tcp_nopush                      off;



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nginx_error_location.log
Type: application/octet-stream
Size: 669828 bytes
Desc: nginx_error_location.log
URL: <>

More information about the nginx mailing list