Nginx uwsgi (104: Connection reset by peer) 同时从上游读取响应头 [英] Nginx uwsgi (104: Connection reset by peer) while reading response header from upstream

查看:61
本文介绍了Nginx uwsgi (104: Connection reset by peer) 同时从上游读取响应头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境是Nginx + uwsgi.

Environment is Nginx + uwsgi.

在某些 GET 请求中从 Nginx 获取 502 错误网关错误.好像跟网址的长度有关.在我们的特殊情况下,它是一长串 GET 参数.缩短GET参数,没有502错误.

Getting a 502 bad gateway error from Nginx on certain GET requests. Seems to be related to the length of the URL. In our particular case, it was a long list of GET parameters. Shorten the GET parameters and no 502 error.

来自 nginx/error.log

From the nginx/error.log

[error] 22113#0: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.1.100, server: server.domain.com, request: "GET <long_url_here>"

uwsgi 错误日志中没有信息.

No information in the uwsgi error log.

推荐答案

在这上面花了很多时间后,我终于弄明白了.有很多对 Nginx 和对等连接重置的参考.他们中的大多数似乎都与 PHP 相关.我找不到特定于 Nginx 和 uwsgi 的答案.

After spending a lot of time on this, I finally figured it out. There are many references to Nginx and connection reset by peer. Most of them seemed to be related to PHP. I couldn't find an answer that was specific to Nginx and uwsgi.

我终于找到了对 fastcgi 的引用和 502 错误网关错误(https://support.plesk.com/hc/en-us/articles/213903705).这导致我在 uwsgi 配置中寻找缓冲区大小限制,该限制作为 buffer-尺寸.默认值为 4096.从文档中,它说:

I finally found a reference to fastcgi and a 502 bad gateway error (https://support.plesk.com/hc/en-us/articles/213903705). That lead me to look for a buffer size limit in the uwsgi configuration which exists as buffer-size. The default value is 4096. From the documentation, it says:

如果您计划接收带有大量标头的大型请求,您可以将此值增加到 64k (65535).

If you plan to receive big requests with lots of headers you can increase this value up to 64k (65535).

uwsgi的配置方式有很多种,我碰巧用的是.ini文件.所以在我的 .ini 文件中我试过:

There are many ways to configure uwsgi, I happen to use a .ini file. So in my .ini file I tried:

buffer-size=65535

这解决了问题.你可以根据口味调整它.也许从最大值开始,然后再返回,直到获得可接受的值,或者将其保留在最大值.

This fixed the problem. You can adjust that to taste. Maybe start with the max and work back until you have an acceptable value, or just leave it at the max.

这令人沮丧,因为 uwsgi 方面没有错误.

This was frustrating to track down because there was no error on the uwsgi side of things.

这篇关于Nginx uwsgi (104: Connection reset by peer) 同时从上游读取响应头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆