nginx访问日志:
0 1 2 3 |
218.18.*.* - - [10/Sep/2014:13:27:50 +0800] "POST /index.php?date=2014-09-09&module=Live&action=getLastVisitsStart&segment=&idSite=2&period=day HTTP/1.1" 499 0 "http://count.t4x.org/index.php?module=CoreHome&action=index&idSite=2&period=day&date=yesterday" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0" 218.18.*.* - - [10/Sep/2014:13:27:50 +0800] "POST /index.php?date=2014-09-09&module=Annotations&action=getEvolutionIcons&idSite=2&period=day&lastN=30 HTTP/1.1" 499 0 "http://count.t4x.org/index.php?module=CoreHome&action=index&idSite=2&period=day&date=yesterday" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0" 218.18.*.* - - [10/Sep/2014:13:27:50 +0800] "POST /index.php?date=2014-09-09&module=Dashboard&action=getAllDashboards&idSite=2&period=day HTTP/1.1" 499 0 "http://count.t4x.org/index.php?module=CoreHome&action=index&idSite=2&period=day&date=yesterday" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0" 218.18.*.* - - [10/Sep/2014:13:27:50 +0800] "POST /index.php?date=2014-09-09&module=ExampleRssWidget&action=rssPiwik&widget=1&idSite=2&period=day HTTP/1.1" 499 0 "http://count.t4x.org/index.php?module=CoreHome&action=index&idSite=2&period=day&date=yesterday" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0" |
nginx定义错误码:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
[root@hz logs]# cd /byrd/tools/nginx-1.7.1 [root@hz nginx-1.7.1]# grep 499 . -r ./CHANGES: *) Bugfix: zero status code was logged instead of 499 status code; the ./CHANGES: with 499 status code. ./CHANGES: *) Change: now the 499 error could not be redirected using an ./CHANGES.ru: *) Исправление: вместо кода ответа 499 в лог записывался код 0; ошибка ./CHANGES.ru: завершался с кодом 499. ./CHANGES.ru: *) Изменение: ошибку 499 теперь нельзя перенаправить с помощью директивы ./src/http/ngx_http_core_module.c: if (err->status == NGX_ERROR || err->status == 499) { ./src/http/ngx_http_request.h:#define NGX_HTTP_CLIENT_CLOSED_REQUEST 499 ./src/http/ngx_http_special_response.c: ngx_null_string, /* 499, client has closed connection */ Binary file ./objs/nginx matches [root@hz nginx-1.7.1]# grep NGX_HTTP_CLIENT_CLOSED_REQUEST . -r ./src/http/ngx_http_upstream.c: NGX_HTTP_CLIENT_CLOSED_REQUEST); ./src/http/ngx_http_upstream.c: NGX_HTTP_CLIENT_CLOSED_REQUEST); ./src/http/ngx_http_upstream.c: NGX_HTTP_CLIENT_CLOSED_REQUEST); ./src/http/ngx_http_upstream.c: NGX_HTTP_CLIENT_CLOSED_REQUEST); ./src/http/ngx_http_upstream.c: NGX_HTTP_CLIENT_CLOSED_REQUEST); ./src/http/ngx_http_upstream.c: NGX_HTTP_CLIENT_CLOSED_REQUEST); ./src/http/ngx_http_upstream.c: NGX_HTTP_CLIENT_CLOSED_REQUEST); ./src/http/ngx_http_upstream.c: NGX_HTTP_CLIENT_CLOSED_REQUEST); ./src/http/ngx_http_upstream.c: || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST) ./src/http/ngx_http_request.h:#define NGX_HTTP_CLIENT_CLOSED_REQUEST 499 ./src/http/ngx_http_request.c: || rc == NGX_HTTP_CLIENT_CLOSED_REQUEST ./src/http/ngx_http_request.c: ngx_http_finalize_request(r, NGX_HTTP_CLIENT_CLOSED_REQUEST); |
原因①:
0 1 2 3 |
if (!u->cacheable) { ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST); } |
原因②:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
if (!u->cacheable && u->peer.connection) { ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, "kevent() reported that client prematurely closed " "connection, so upstream connection is closed too"); ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST); return; } if (!u->cacheable && u->peer.connection) { ngx_log_error(NGX_LOG_INFO, ev->log, err, "epoll_wait() reported that client prematurely closed " "connection, so upstream connection is closed too"); ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST); return; } if (!u->cacheable && u->peer.connection) { ngx_log_error(NGX_LOG_INFO, ev->log, err, "client prematurely closed connection, " "so upstream connection is closed too"); ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST); return; } |
原因③:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, "kevent() reported that client prematurely closed " "connection"); if (u->peer.connection == NULL) { ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST); } ngx_log_error(NGX_LOG_INFO, ev->log, err, "epoll_wait() reported that client prematurely closed " "connection"); if (u->peer.connection == NULL) { ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST); } ngx_log_error(NGX_LOG_INFO, ev->log, err, "client prematurely closed connection"); if (u->peer.connection == NULL) { ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST); } |
原因④:
0 1 2 3 4 |
if (r->connection->error) { ngx_http_upstream_finalize_request(r, u, NGX_HTTP_CLIENT_CLOSED_REQUEST); return; } |
解决方法:
①:未成功[解决方法来自:http://www.lc365.net/blog/b/23997/]
0 |
proxy_ignore_client_abort on; #如果客户端断开请求,也保持后端的下载 |
②:
0 |
参考文档:http://www.kankanews.com/ICkengine/archives/112184.shtml
参考文档:http://www.douban.com/note/315222037/
参考文档:http://www.badnotes.com/2013/09/25/nginx_499_code/SourceByrd's Weblog-https://note.t4x.org/system/ngx-http-client-closed-request/
SourceByrd's Weblog-https://note.t4x.org/system/ngx-http-client-closed-request/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!