Background

We’re Installing Seafile Using Docker Compose and Employing Nginx for Reverse Proxy.

OS: Ubuntu 22.04.2 LTS Seafile Version: Docker Community Edition 8.0.7 Nginx Version: nginx/1.18.0 (Ubuntu)

Symptom

I am downloading large files in seafile with file size of 2.3GB and after some time it says download failed. But I can successfully download small files.

Analysis Process

Determine the direction of troubleshooting based on the phenomenon

  1. I’ve successfully downloaded many small files of a few tens of MB in the past, so I think the reason for the error has to do with the file size!
  2. First I tried to download another 1.5G file and it failed. Then I made several more attempts and found that the browser’s file download progress bar went close to 1GB with an error.

View nginx logs

  1. I started looking at the nginx error logs and saw the error logs.
    1
    
    upstream prematurely closed connection while reading upstream, client: 192.168.5.65...
    
  2. I’m downloading the file on the server without going through nginx, it worked fine. So I’ve decided the problem is with nginx.
  3. I tried to search nginx download large file 1G and found nginx-does-not-serve-large-files
  4. I found proxy_max_temp_file_size and proxy_buffering in ngx_http_proxy_module. then I confirmed the default size of proxy_max_temp_file_size is 1GB. I tried to set the proxy_max_temp_file_size 0; and proxy_buffering off; in the conf of nginx and download the file again. The file was successfully downloaded.

Solution

Change proxy_buffering off, add proxy_buffering off; to the conf of nginx.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
server {
    ...
    proxy_buffering off;
    proxy_max_temp_file_size 0;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    ...
    location / {
        proxy_pass   http://seafile;
    }
}