如何解决上游在发送到客户端时过早关闭连接
当我尝试从我的服务器下载文件时遇到问题。当我通过快速互联网连接下载文件时,一切都很好..但互联网速度较慢的其他用户无法完成下载。 下载文件大约在 7 分钟后中止并出现错误:
[error] 194621#194621: *135815 upstream prematurely closed connection while sending to client...
我的服务器配置(基于 docker)
前端Nginx:
location / {
proxy_pass http://172.26.141.15;
proxy_http_version 1.1;
proxy_buffering off;
proxy_redirect off;
proxy_request_buffering off;
proxy_connect_timeout 7200s;
proxy_send_timeout 7200s;
proxy_read_timeout 7200s;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_set_header Host $host;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header If-Range "";
后端Nginx
upstream ui_loadbalancer {
ip_hash;
server filehost-PHP:9000; # location of my first PHP-fpm server
}
server {
listen 80;
client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 80M;
keepalive_timeout 15;
sendfile on;
sendfile_max_chunk 512k;
send_timeout 10;
location / {
try_files $uri /index.PHP$is_args$args;
}
location ~ ^/index\.PHP(/|$) {
fastcgi_split_path_info ^(.+\.PHP)(/.*)$;
fastcgi_pass ui_loadbalancer;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
另外我通过
扩展了PHP.ini"max_execution_time = 7200"
和 PHP-fpm
"request_terminate_timeout = 7200"
您知道为什么下载会在大约 7 分钟后中止吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。