Nginx proxy truncates large file downloads to 1.1G

Hello All:

So nginx so far has been running great. Today however I discovered that
when downloading a file larger than 1G (ie 1.5G) it will always fail
leaving the client with a file of 1.1G and an incomplete download. If I
point directly to the webserver the download completes properly.
Downloading over a slow or local or fast link does not change the
problem. Its the file size that appears to be causing the issue. Any
size of file download which is under 1G works and downloads with no
issues.

I suspect its some issue with proxy buffering however I have not been
able to come up with the secret sauce to make it work. Below is the
last iteration of my config which still truncates large file downloads.
The boxes that nginx is running on are a dedicated dual core dual Xeon
3Ghz with 8G of ram.

Also there does not seem to be anything in the error logs when this
occurs.

Regards,
Duane

The files
user nginx;
worker_processes 4;
events {
worker_connections 1024;
use epoll;
multi_accept on;
}

http { #http
include mime.types;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript
text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
#disable for IE 6
gzip_disable “MSIE [1-6].(?!.*SV1)”;

POST size limit

# Set File upload limit at 2G
client_max_body_size 2000M;
sendfile        on;
keepalive_timeout  65;

server { #server80
listen 192.168.1.231:80 ;
server_name x.x.com;

##Blocked IP address message
error_page 403 = http://x.y.com/monitor/x_403.html;

 ### Add SSL specific settings here ###
    keepalive_timeout    240;
    access_log  /nginx/cust-SSL/logs/access.log;
    error_log /nginx/cust-SSL/logs/error.log;

location /nginx_status {
      stub_status on;
      access_log   off;
      allow 1.1.1.0.0/24;

      deny all;
    }

##FILE DOWNLOAD OPTIONS --this is the bit that is not working.
location /path_for_testing {
##hosts to allow
proxy_buffering on;
#proxy_buffer_size 16k;
proxy_buffer_size 64k;
proxy_buffers 64 64k;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://x.y.com:80/path_for_testing;
proxy_redirect off;
}

##FIX CONTENT

location /different_path {
subs_filter_types text/html text/css text/xml;
#subs_filter http://x.x.com/sf/ http://x.x.com/sf/ i;
subs_filter http://x.x.com/svn/ http://x.x.com/svn/ i;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://x.x.com:80/different_path/;
proxy_redirect off;
}

Proxy the rest of the site, temporarily commented out as I am

debugging the in the path for testing section.

location / {
#proxy_buffering on;
#proxy_buffer_size 16k;
#proxy_buffers 32 16k;
#client_body_buffer_size 128k;
#proxy_busy_buffers_size 64k;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://x.x.com:80/;
proxy_redirect off;
}

On Sun, Dec 5, 2010 at 5:21 PM, Duane M. [email protected]
wrote:

So nginx so far has been running great. Today however I discovered that
when downloading a file larger than 1G (ie 1.5G) it will always fail
leaving the client with a file of 1.1G and an incomplete download. If I
point directly to the webserver the download completes properly.
Downloading over a slow or local or fast link does not change the
problem. Its the file size that appears to be causing the issue. Any
size of file download which is under 1G works and downloads with no issues.

I have to ask - you’ve tried this on multiple client machines? You’re
sure it’s not the local browser/browser cache/local disk space/temp
space/etc? :slight_smile: Sometimes the small things are to blame

(also server swap space, server temp space [in case it needed to keep
it on disk somewhere temporarily, etc, etc])

Just my two cents if you’re waiting for a response and haven’t checked
those silly things out (“why is my server acting up?” and later you
realize you’re out of disk space, that’s why…)

Even i am facing the same problem but i m yet to figure out the exact
cause of it…The disk space seems to be fine…In my case when
downloading a file larger than 1G(1.2 GB) it will truncate to 1 GB…

On Sun, 2010-12-05 at 20:21 -0500, Duane M. wrote:

So nginx so far has been running great. Today however I discovered that
when downloading a file larger than 1G (ie 1.5G) it will always fail
leaving the client with a file of 1.1G and an incomplete download.

Try disabling gzip and see if that helps. If so, tuning the gzip
settings might be in order.

Cliff

Hello!

On Wed, Sep 14, 2011 at 08:57:28AM +0200, JAZZ F. wrote:

Even i am facing the same problem but i m yet to figure out the exact
cause of it…The disk space seems to be fine…In my case when
downloading a file larger than 1G(1.2 GB) it will truncate to 1 GB…

proxy_max_temp_file_size, when reached, causes relative long delay
in reading from upstream server; this may cause timeout on
upstream server, seen as “truncation”.

There are 3 possible workarounds:

  1. Use smaller proxy_max_temp_file_size to reduce delay in
    reading.

  2. Use larger proxy_max_temp_file_size to avoid hitting it.

  3. Use larger timeout on upstream server.

Maxim D.