[nginx日志路径]Nginx日志错误码499的问题解决方法

时间:2019-10-02  来源:nginx  阅读:

nginx访问日志:

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.111cn.net/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.111cn.net/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.111cn.net/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.111cn.net/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定义错误码:

[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);

原因①:

 if (!u->cacheable) {
           ngx_http_upstream_finalize_request(r, u,
                                               NGX_HTTP_CLIENT_CLOSED_REQUEST);
        }

原因②:

        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;
    }

原因③:

        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);
    }

原因④:


    if (r->connection->error) {
        ngx_http_upstream_finalize_request(r, u,
                                           NGX_HTTP_CLIENT_CLOSED_REQUEST);
        return;
    }

解决方法:

①:未成功[解决方法

proxy_ignore_client_abort on;    #如果客户端断开请求,也保持后端的下载

[nginx日志路径]Nginx日志错误码499的问题解决方法

http://m.bbyears.com/caozuoxitong/70841.html

推荐访问:nginx日志分割 nginx日志配置
相关阅读 猜你喜欢
本类排行 本类最新