Download of shared pictures/ videos fails often - is fastcgi_buffers off the right solution?

Nextcloud version (eg, 12.0.2): 17.0.1
Operating system and version (eg, Ubuntu 17.04): lastest Docker-container
Apache or nginx version (eg, Apache 2.4.25): Nginx
PHP version (eg, 7.1): 7.3.11

The issue you are facing:
When i share a file (mostly images and videos) to friends of mine they often tell me, that they were unable to download the files.
I tried it out for myself and noticed that most of the time the download works, but sometimes it just stops in the middle of the download process.
I thought this problem must be related to the webserver, so i checked my Nginx logs and found this:

172.20.0.1 - - [15/Dec/2019:13:25:19 +0000] "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&
files=DSC_0155.JPG&downloadStartSecret=rfeofy60av8 HTTP/1.1" 200 4133129 "-" "Mozilla/
5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0" "178.202.247.1
39"                                
                                                   
                
172.20.0.1 - - [15/Dec/2019:13:25:26 +0000] "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&
files=20190103_104830.jpg&downloadStartSecret=bq8spt05jjg HTTP/1.1" 200 3997309 "-" "M
ozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0" "178.20
2.247.139"                              

                                             
                                    
2019/12/15 13:25:27 [warn] 9#9: *248148 an upstream response is buffered to a temporar
y file /var/cache/nginx/fastcgi_temp/8/15/0000000158 while reading upstream, client: 1
72.20.0.1, server: , request: "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&files=DSC_0222
.JPG&downloadStartSecret=5v04c2ezun4 HTTP/1.1", upstream: "fastcgi://172.20.0.4:9000",

 
172.20.0.1 - - [15/Dec/2019:13:25:27 +0000] "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&
files=DSC_0222.JPG&downloadStartSecret=5v04c2ezun4 HTTP/1.1" 200 4143302 "-" "Mozilla/
5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0" "178.202.247.1
39"                                                                                   
26.0stable-Win64 (build 20190927) (Nextcloud)" "178.202.247.139"      

   
172.20.0.1 - - [15/Dec/2019:13:25:19 +0000] "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&
files=DSC_0155.JPG&downloadStartSecret=rfeofy60av8 HTTP/1.1" 200 4133129 "-" "Mozilla/
5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0" "178.202.247.1
39"         

          
172.20.0.1 - - [15/Dec/2019:13:25:26 +0000] "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&
files=20190103_104830.jpg&downloadStartSecret=bq8spt05jjg HTTP/1.1" 200 3997309 "-" "M
ozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0" "178.20
2.247.139"                    

                              
2019/12/15 13:25:27 [warn] 9#9: *248148 an upstream response is buffered to a temporar
y file /var/cache/nginx/fastcgi_temp/8/15/0000000158 while reading upstream, client: 1
72.20.0.1, server: , request: "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&files=DSC_0222
.JPG&downloadStartSecret=5v04c2ezun4 HTTP/1.1", upstream: "fastcgi://172.20.0.4:9000",
            

 
172.20.0.1 - - [15/Dec/2019:13:25:27 +0000] "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&
files=DSC_0222.JPG&downloadStartSecret=5v04c2ezun4 HTTP/1.1" 200 4143302 "-" "Mozilla/
5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0" "178.202.247.1
39"                          

                                                         
2019/12/15 13:25:30 [warn] 7#7: *248154 an upstream response is buffered to a temporar
y file /var/cache/nginx/fastcgi_temp/0/16/0000000160 while reading upstream, client: 1
72.20.0.1, server: , request: "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&files=IMG_9878
.JPG&downloadStartSecret=2qwdq4citol HTTP/1.1", upstream: "fastcgi://172.20.0.4:9000",


 
172.20.0.1 - - [15/Dec/2019:13:25:30 +0000] "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&
files=IMG_9878.JPG&downloadStartSecret=2qwdq4citol HTTP/1.1" 200 4370028 "-" "Mozilla/
5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0" "178.202.247.1
39"                                     

                  
2019/12/15 13:25:32 [warn] 9#9: *248156 an upstream response is buffered to a temporar
y file /var/cache/nginx/fastcgi_temp/1/16/0000000161 while reading upstream, client: 1
72.20.0.1, server: , request: "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&files=IMG_9833
.JPG&downloadStartSecret=qs87hjopl1r HTTP/1.1", upstream: "fastcgi://172.20.0.4:9000",
   

 
172.20.0.1 - - [15/Dec/2019:13:25:32 +0000] "GET /s/cJ5Qg4YPAXAeaP4/download?path=%2F&
files=IMG_9833.JPG&downloadStartSecret=qs87hjopl1r HTTP/1.1" 200 6395212 "-" "Mozilla/
5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0" "178.202.247.1
39"                                          

So it seems to me that something with the buffers doesn’t work, but i’m not sure about this.
I tried disabling the response buffering with this line:

fastcgi_buffering off;

I tried it a few times and for now i don’t have the download problems anymore, but is this the correct way to handle the problem?

Is this the first time you’ve seen this error? (Y/N): No, this happens often and was reported to me multiple times when sharing files to my friends.

Thanks in advance, tell me if you need additional information.

push anybody got an idea?

Hi,

I have encountered the same problem after upgrading from 18.0.? to 20.0.9. Not sure if upgrade triggered it, but nothing has changed otherwise with the config.

Applying the fastcgi_buffering off to fastcgi params and conf for nginx has solved the unknown issue.

System is up to date debian 10 with:

  • nginx
  • php7.3-fpm (local connection via unix socket)
  • mariadb (local connection via unix socket)
    *redis + opcache