nginx - 上游在发送到客户端时过早关闭连接
问题描述
当我尝试从我的服务器下载文件时遇到问题。当我通过快速互联网连接下载文件时,一切都很好..但其他互联网速度慢的用户无法完成下载。下载文件在 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 分钟后中止?
解决方案
推荐阅读
- swiftui - 如果父视图中已有工作表,则不能在 SwiftUI 的子视图中显示工作表
- java - 为什么 Criteria API 会抛出 StackOverFlow 异常?
- google-sheets - 通过比较一些值从其他电子表格中获取数据
- atl - 关于 ATL 140 ,这是 DECLARE_REGISTRY 中的错字吗?
- android - 自定义 FooterBarLayout 中没有滚动以跟随 AppBarLayout
- cakephp - 更改路径搜索顺序
- amazon-web-services - 为什么 aws s3 传输加速不起作用?
- android - 如何为我的 Android 应用程序创建一个圆形图标?
- c# - 如何循环 C# ARGGIS 异步方法(查看帖子以获取方法代码)
- math - 在 3D 中垂直于起始边缘捕捉拖动的鼠标位置