When downloading a large file, Nginx times out and the download fails

Symptom 1:
When the download file reaches 1 minute, the connection timeout is reported.

Solution:
The default timeout of nginx reverse proxy is 60s, and the download of large files exceeds the threshold, you can specify the timeout time:

              location /api {
                        proxy_pass http://127.0.0.1:5000;
                        # nginx跟后端服务器连接超时时间
                        proxy_connect_timeout 300;

                        # 后端服务器数据回传超时时间
                        proxy_send_timeout 300;

                        # 连接成功后,后端服务器响应超时时间
                        proxy_read_timeout 300;
                        proxy_set_header Host $host:$server_port;
                }

Symptom 2:
The download through the nginx reverse proxy fails, but the download directly through the port is normal.

Solution:
It may be a problem of nginx cache limit, just disable the cache.

proxy_pass http://127.0.0.1:5002;
proxy_redirect default;
proxy_buffering off;



Author: orionc
Link: https://www.jianshu.com/p/d73e8425ab48
Source: Jianshu
The copyright belongs to the author. For commercial reprint, please contact the author for authorization, for non-commercial reprint, please indicate the source.


Guess you like

Origin blog.csdn.net/huawangxin/article/details/123324498