欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

在上游读取 #5706 时,上游过早关闭连接 Upstream prematurely closed connection while reading upstream #5706 有大用 有大大用

Nginx出现upstream prematurely closed connection while reading response header from upstream错误

nip27 发布于 2014/09/12 17:00
 
阅读 40K+
 
收藏 1
 

在nginx做反向代理时在日志中出现很多如下的错误信息,不知道如何解决,希望得到帮助!

2014/09/12 16:38:40 [error] 10682#0: *357 upstream prematurely closed connection while reading response header from upstream, client: 192.168.2.223, server: localhost, request: "GET /agentless/test300k.jsp HTTP/1.1", upstream: "http://192.168.4.67:80/agentless/test300k.jsp", host: "192.168.4.89:89"

nginx配置:

worker_processes  2;

events {
    use epoll;
    worker_connections  10240;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;
    server_tokens off;
    rewrite_log on;

    upstream nacweb {
        server 192.168.4.67;
    }

    server {
        listen          89;
        server_name     localhost;

        access_log      logs/access.log;
        error_log       logs/error.log;

        keepalive_timeout    60;

        location /agentless/ {
            proxy_pass http://nacweb;
        }
    }
}


1
xialeistudio
xialeistudio 

报错的大概意思是不能从上流服务器读取响应

你看看你的代理服务器是不是有问题喔

0
FeiFeiZheng
FeiFeiZheng 

是不是这个http://192.168.4.67:80/agentless/test300k.jsp 请求处理有问题,如果是tomcat 的话,可以把它的access.log功能开启,看看对这个 jsp的处理,它返回的是什么,同时可以看看192.168.4.67有没有异常, 这个错误的意思是 nginx不能从后端的服务器(192.168.4.67:80)获取响应头

0
小莫0
小莫0 
是程序的问题吧?你看下代码...看下有没有问题...
0
easywang
easywang 

我也碰到这个问题,设置了超时时间和内存大小,就可以了,当然要看你实际场景

来自  https://www.oschina.net/question/140787_168071



在上游读取 #5706 时,上游过早关闭连接        

                                                            

评论

申请人                    
没有人分配                
标签                
还没有                
项目                    
还没有                
里程碑                    
没有里程碑                
4名参与者                    
@codesmaker@ogoffart@soichih@marianopw                    
@codesmaker                

codemaker 评论道 on 16 Apr 2017                            

预期的行为                                                

Owncloud客户端应该成功同步大文件                                                

实际行为                                                

无法同步大文件。一旦文件达到1GB,同步就会停止。                                                

服务器配置                                                

操作系统:Debian Jessie 8                                                

Web服务器:Apache / 2.4.10                                                

数据库:MySQL 5.5.54                                                

PHP版本:PHP 7.0.17-1~docdeb + 8.1                                                

ownCloud版本:9.1.4                                                

存储后端(外部存储):                                                

客户端配置                                                

客户端版本:2.3.1                                                

操作系统:Windows 10                                                

操作系统语言:英语                                                

客户端软件包使用的Qt版本(仅限Linux,另请参见“设置”对话框):                                                

客户端包(来自ownCloud或发行版)(仅限Linux):                                                

客户端的安装路径:                                                

日志                                                

请使用Gist(https://gist.github.com/)或类似的代码贴纸来获取更长的
日志。                                                

  1. Web服务器错误日志:
    2017/04/16 11:00:59 [错误] 28461#28461:* 2072上游超时(110:连接超时)从上游读取响应头,客户端:192.168.1.1,服务器:owncloud .example.com,请求:“GET /remote.php/webdav/NewArrivals/file HTTP / 1.1”,上游:“ http://192.168.1.204:80/remote.php/webdav/NewArrivals/file ”,主持人: “owncloud.example.com”

  2. 服务器日志文件:ownCloud log(data / owncloud.log):
    {“reqId”:“cYxtvnjVwfi7BJd9ks5q”,“remoteAddr”:“192.168.1.1”,“app”:“PHP”,“message”:“为foreach提供的参数无效()at /var/www/owncloud/apps/activity/lib/Formatter/CloudIDFormatter.php#89","level":3,"time":"2017-04-16T12:50:50+02:00“ ,“方法”:“GET”,“url”:“/ ocs / v1.php / cloud / activity?page = 0&pagesize = 100&format = json”,“user”:“user”} 
    {“reqId”:“WcFGzfKmU0dyKXkVKyIY” “remoteAddr”: “192.168.1.1”, “应用程序”: “PHP”, “消息”:“FSEEK():stream不支持在/var/www/owncloud/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php#74","level":3,"time"::2017-04-16T12:51 :03 + 02:00" , “方法”: “GET”, “URL”: “/ remote.php / WebDAV的/ NewArrivals /文件”, “用户”: “用户”}

嗨,                                                

我有2个Owncloud实例,安装在两个不同的国家/地区。两种设置都是相同的。它们位于反向代理(Nginx)之后,它将连接重定向到后端服务器。如上所述,owncloud安装几乎是标准的(Apache + MySQL + PHP7)。当我尝试同步大文件(10GB +)时,同步将停止并显示“连接已关闭”错误。我从Nginx服务器上得到了上面提到的错误消息。很明显,连接超时。我试图增加PHP中的时间值(最大执行时间)和反向代理,但没有任何帮助。这就是我在反向代理中所拥有的:
location / { proxy_connect_timeout 159s; proxy_send_timeout 600; proxy_read_timeout 600; proxy_buffer_size 64k; proxy_buffers 16 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; proxy_pass http://192.168.1.204; }
还值得注意的是我正在使用联合共享。如何跟踪究竟何时超时?                                                

@ogoffart                    
合作者                                

ogoffart 评论道 on 16 Apr 2017                                

嗨,                                                    

我不认为这是一个客户端错误。很可能是服务器端的配置问题。
请在论坛或用户邮件列表中提出问题。https://owncloud.org/support/
确保还要检查https://github.com/owncloud/documentation/wiki/Uploading-files-up-to-16GB 和https://doc.owncloud.org/server /10.0/admin_manual/configuration_files/big_file_upload_configuration.html                                                    

@ogoffart ogoffart 关闭了这个 on 16 Apr 2017                    

@codesmaker                    
作者                                

codemaker 评论道 on 17 Apr 2017                                

嗨Ogoffart,                                                    

确实。这是一个服务器配置。我只需要在Ngnix(前端反向代理)上设置以下内容:
proxy_request_buffering off;
proxy_buffering off;                                                    

感谢您的帮助和链接。                                                    

@soichih                    

soichih 评论道 on 16 Feb 2018                                

@codesmaker谢谢。我添加了“proxy_buffering off”。这解决了类似的问题。如果没有此选项,nginx会抛出错误消息“上游过早关闭连接,同时读取上游”并终止连接。                                                    

但是..我不太明白为什么添加这个选项会解决这个问题。根据nginx文档,缓冲应该在达到最大缓冲区大小时自动停止(默认情况下应该非常小)。有人可以解释Nginx内部的情况吗?                                                    

@marianopw                    

marianopw 评论道 on 3 Mar 2018                                

我的反向代理有类似的问题。
这是最终为我做的配置:
location / { 
proxy_http_version 1.1; 
proxy_set_header升级$ http_upgrade; 
proxy_set_header连接“升级”; 
proxy_set_header主机$ http_host; 
proxy_set_header X-Real-IP $ remote_addr; 
proxy_set_header X-Forward-For $ proxy_add_x_forwarded_for; 
proxy_set_header X-Forward-Proto http; 
proxy_set_header X-Nginx-Proxy true; 
proxy_temp_file_write_size 64k; 
proxy_connect_timeout 10080s; 
proxy_send_timeout 10080; 
proxy_read_timeout 10080; 
proxy_buffer_size 64k; 
proxy_buffers 16 32k; 
proxy_busy_buffers_size 64k;
proxy_redirect off; 
proxy_request_buffering off; 
proxy_buffering off; 
proxy_pass http://192.168.1.201:9100/ ; 
}                                                    

@minkyuxyz minkyuxyz 引用了这个问题 on 31 May 2018                    

 打开                    

上游过早关闭连接错误 #23                    

@federicopuntoni federicopuntoni 引用了这个问题 on 12 Oct 2018                    

 关闭                    

上游过早关闭 #92                    

@nyemenzo nyemenzo 引用了这个问题 on 21 Feb                    

 打开                    

Garena缺少缓存 #78                    

@omarroth omarroth 引用了这个问题 19天前                    

 关闭                    

上游过早关闭连接 #604                     


                   


                   

来自  https://github.com/owncloud/client/issues/5706                    


                   


                   


                   


                   


                   


                   

aaaaaaaaaaaaaaaa

Upstream prematurely closed connection while reading upstream #5706        

 Closed        
codesmaker opened this issue on 16 Apr 2017 · 4 comments

Comments

Projects
None yet                
4 participants
@codesmaker@ogoffart@soichih@marianopw                    
@codesmaker                

commented on 16 Apr 2017                            

Expected behaviour

Owncloud client should successfully sync large files

Actual behaviour

Can not sync large files. Syncing stops as soon as a file reaches 1GB.

Server configuration

Operating system: Debian Jessie 8

Web server: Apache/2.4.10

Database: MySQL 5.5.54

PHP version: PHP 7.0.17-1~dotdeb+8.1

ownCloud version: 9.1.4

Storage backend (external storage):

Client configuration

Client version: 2.3.1

Operating system: Windows 10

OS language: English

Qt version used by client package (Linux only, see also Settings dialog):

Client package (From ownCloud or distro) (Linux only):

Installation path of client:

Logs

Please use Gist (https://gist.github.com/) or a similar code paster for longer
logs.

  1. Web server error log:
    2017/04/16 11:00:59 [error] 28461#28461: *2072 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.1.1, server: owncloud.example.com, request: "GET /remote.php/webdav/NewArrivals/file HTTP/1.1", upstream: "http://192.168.1.204:80/remote.php/webdav/NewArrivals/file", host: "owncloud.example.com"

  2. Server logfile: ownCloud log (data/owncloud.log):
    {"reqId":"cYxtvnjVwfi7BJd9ks5q","remoteAddr":"192.168.1.1","app":"PHP","message":"Invalid argument supplied for foreach() at /var/www/owncloud/apps/activity/lib/Formatter/CloudIDFormatter.php#89","level":3,"time":"2017-04-16T12:50:50+02:00","method":"GET","url":"/ocs/v1.php/cloud/activity?page=0&pagesize=100&format=json","user":"user"}
    {"reqId":"WcFGzfKmU0dyKXkVKyIY","remoteAddr":"192.168.1.1","app":"PHP","message":"fseek(): stream does not support seeking at /var/www/owncloud/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php#74","level":3,"time":"2017-04-16T12:51:03+02:00","method":"GET","url":"/remote.php/webdav/NewArrivals/file","user":"user"}

Hi,

I have 2 Owncloud instances which are installed in two different countries. Both setups are identical. They are behind a reverse proxy (Nginx) that redirect the connections to the backend server. The owncloud installation is almost standard (Apache+MySQL+PHP7) as mentioned above. When I try to sync a large file (10GB+), the sync stops with an error "connection closed". I get the error message I mentioned above from the Nginx server. It is clear that the connection times out. I tried to increase the timout values in PHP (max execution time) and the reverse proxy but nothing helped. This is what I have in the reverse proxy:
location / { proxy_connect_timeout 159s; proxy_send_timeout 600; proxy_read_timeout 600; proxy_buffer_size 64k; proxy_buffers 16 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; proxy_pass http://192.168.1.204; }
It's also worth noting that I'm using federated shares. How can I track what exactly is timing out?

@ogoffart                    
Collaborator                                

commented on 16 Apr 2017                                

Hi,

I don't think this is a client bug. Most likely a configuration problem on the server side.
Please ask the question on the forum or user mailinglist. https://owncloud.org/support/
Make sure to also check https://github.com/owncloud/documentation/wiki/Uploading-files-up-to-16GBandhttps://doc.owncloud.org/server/10.0/admin_manual/configuration_files/big_file_upload_configuration.html                                                    

@ogoffart ogoffart closed this on 16 Apr 2017                    

@codesmaker                    
Author                                

commented on 17 Apr 2017                                

Hi Ogoffart,

Indeed. It was a server configuration. I just had to set the following on the Ngnix (frontend reverse proxy):
proxy_request_buffering off;
proxy_buffering off;                                                    

Thanks for the help and for the links.

@soichih                    

commented on 16 Feb 2018                                

@codesmaker Thanks. I added "proxy_buffering off;" which fixed a similar issue. Without this option, nginx throws the error message "upstream prematurely closed connection while reading upstream" and connection gets terminated.

But.. I don't quite understand why adding this option would fix this. According to nginx documentation, buffering should automatically stop when it reaches the maximum buffer size (should be very small by default). Can someone explain what is going on inside Nginx?

@marianopw                    

commented on 3 Mar 2018                                

Had a similar problem with my reverse proxy.
This is the configuration that finally did it for me:
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-Nginx-Proxy true;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 10080s;
proxy_send_timeout 10080;
proxy_read_timeout 10080;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_redirect off;
proxy_request_buffering off;
proxy_buffering off;
proxy_pass http://192.168.1.201:9100/;
}

@minkyuxyz minkyuxyz referenced this issue on 31 May 2018                    

 Open                    

Upstream prematurely closed connection error #23                    

@federicopuntoni federicopuntoni referenced this issue on 12 Oct 2018                    

 Closed                    

upstream prematurely closed #92                    

@nyemenzo nyemenzo referenced this issue on 21 Feb                    

 Open                    

Garena missing cache #78                    

@omarroth omarroth referenced this issue 19 days ago                    

 Closed                    

upstream prematurely closed connection #604                    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment            


来自  https://github.com/owncloud/client/issues/5706

普通分类: