一.499是nginx自定义的http状态码。

在源码中有这么一段说明

/*

 * HTTP does not define the code for the case when a client closed

 * the connection while we are processing its request so we introduce

 * own code to log such situation when a client has closed the connection

 * before we even try to send the HTTP header to it

 */

nginx定义的一个状态码,用于表示这样的错误:服务器返回http头之前,客户端就提前关闭了http连接,这很有可能是因为服务器端处理的时间过长或者客户端网络异常。


二.proxy_ignore_client_abort

Determines whether the connection with a proxied server should be closed when a client closes the connection without waiting for a response.

当客户端没有等待服务器返回就主动关闭连接时,服务端要不要关闭客户端连接。


1.关闭时:如果客户端端主动关闭请求或者客户端网络断掉,Nginx会记录499,同时request_time是后端已经处理的时间,而upstream_response_time为“-“。

日志格式:[$time_local] $request_length $status $upstream_status $request_time $upstream_response_time

日志记录:[07/Jun/2018:08:35:33 +0800] 1326 499 - 0.379 -


2.开启时:如果客户端端主动关闭请求或者客户端网络断掉,Nginx会等待后端处理完(或者超时),然后记录后端的返回信息到日志。所以,如果后端返回200,就记录200 ;如果后端返回5XX,那么就记录5XX。