我得到了很多499 NGINX错误码。我知道这是客户端的问题。这不是NGINX或我的uWSGI堆栈的问题。当a得到499时,我注意到uWSGI日志中的相关性。

address space usage: 383692800 bytes/365MB} {rss usage: 167038976
bytes/159MB} [pid: 16614|app: 0|req: 74184/222373] 74.125.191.16 ()
{36 vars in 481 bytes} [Fri Oct 19 10:07:07 2012] POST /bidder/ =>
generated 0 bytes in 8 msecs (HTTP/1.1 200) 1 headers in 59 bytes (1
switches on core 1760)
SIGPIPE: writing to a closed pipe/socket/fd (probably the client
disconnected) on request /bidder/ (ip 74.125.xxx.xxx) !!!
Fri Oct 19 10:07:07 2012 - write(): Broken pipe [proto/uwsgi.c line
143] during POST /bidder/ (74.125.xxx.xxx)
IOError: write error

我正在寻找一个更深入的解释,希望我的NGINX配置uwsgi没有问题。我只看表面。好像是客户的问题。


当前回答

有一次,我得到499“请求已被反病毒禁止”作为AJAX http响应(卡巴斯基互联网安全与轻启发式分析的假阳性,深度启发式分析正确地知道没有任何错误)。

其他回答

对我来说,我已经启用了ufw,但我忘记暴露我的上行端口。_。

使用标准的nginx配置和php-fpm,这个错误很容易重现。

在页面上按下F5按钮将向服务器创建数十个刷新请求。浏览器在刷新时取消之前的每个请求。以我为例,我在客户的网上商店日志文件中发现了数十个499。从nginx的角度来看:如果在下一次刷新请求之前没有将响应传递给客户端,nginx将记录499错误。

mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:32 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)
mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:33 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)
mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:33 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)
mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:33 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)
mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:33 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)
mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:34 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)
mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:34 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)
mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:34 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)
mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:34 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)
mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:35 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)
mydomain.com.log:84.240.77.112 - - [19/Jun/2018:09:07:35 +0200] "GET /(path) HTTP/2.0" 499 0 "-" (user-agent-string)

当然,如果php-fpm处理需要更长的时间(比如一个沉重的WP页面),它可能会导致问题。例如,我听说过php-fpm崩溃,但我相信可以通过正确配置服务来防止崩溃,比如处理对xmlrpc.php的调用。

我们在生产中也得到了499响应码。我们的堆栈是

NGINX, Gunicorn Django 芹菜(异步) Redis芹菜经纪人。 Postgresql

问题: 我们的API没有返回到Gunicorn -> NGINX的响应。因为Redis已关闭(正在加载数据),所以celery将请求传递给.delay()方法以从API卸载工作负载,但它没有返回任何响应。


如何在Django和其他堆栈中重现它?

不从API返回任何响应。NGINX将向客户端发送499响应码。

我们是怎么解决的?

我们检查了堆栈的每个组件,最终找到了一个导致组件,它是Redis。我们注释了.delay()(这个方法使用了Redis)方法调用并测试了API,它工作得很好。

这可能是NGINX返回499的原因之一。 确保您的Web框架是否返回响应。如果它返回200,那么检查你的NGINX配置或客户端。

Nginx中的HTTP 499意味着客户端在服务器响应请求之前关闭了连接。以我的经验,通常是由客户端超时引起的。据我所知,这是Nginx特定的错误代码。

我知道这是一个旧线程,但它完全符合最近发生在我身上的事情,我想我应该在这里记录它。设置(在Docker中)如下:

nginx_proxy nginx Php_fpm运行实际的应用程序。

在应用程序登录提示时,现象为“502网关超时”。检查日志发现:

该按钮通过HTTP POST到/login…所以…… Nginx-proxy收到/login请求,并最终报告超时。 Nginx返回一个499响应,这当然意味着“主机死亡”。 登录请求根本没有出现在FPM服务器的日志中! 在FPM中没有回溯或错误消息…没有,零,zippo,零。

结果发现,问题是无法连接到数据库以验证登录。但如何弄清楚这一点完全是猜测。

The complete absence of application traceback logs ... or even a record that the request had been received by FPM ... was a complete (and, devastating ...) surprise to me. Yes, the application is supposed to log failures, but in this case it looks like the FPM worker process died with a runtime error, leading to the 499 response from nginx. Now, this obviously is a problem in our application ... somewhere. But I wanted to record the particulars of what happened for the benefit of the next folks who face something like this.