linux curl + nginx无法使用keepalive请求

时间:2014-07-24 02:39:57

标签: curl nginx

我正在尝试向localhost发出状态请求,并在error.log文件中获取错误消息。你知道吗,怎么解决这个问题? 或者它可能只是一条信息消息,它始终带有“无保留”数据包。

/usr/bin/curl --no-keepalive -s -m 3 http://127.0.0.1/server-status

/tmp/error.log

2014/07/24 06:03:23 [info] 18038#0: *198319 client 127.0.0.1 closed keepalive connection
2014/07/24 06:04:22 [info] 18038#0: *198398 client 127.0.0.1 closed keepalive connection

/tmp/access.log

127.0.0.1 - - [24/Jul/2014:06:03:23 +0400] "GET /server-status HTTP/1.1" 200 110 "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2"
127.0.0.1 - - [24/Jul/2014:06:04:22 +0400] "GET /server-status HTTP/1.1" 200 110 "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2"

/etc/nginx/nginx.conf

error_log       /var/log/nginx/error.log warn;
http {
    client_body_timeout     10;
    client_header_timeout   10;
    keepalive_timeout       5 5;
    send_timeout            10;
    include /etc/nginx/sites-enabled/*;
}

的/ etc / nginx的/ /本地主机启用位点-

server {
    listen localhost;
    server_name nginx_status.localhost;
    access_log      /tmp/access.log;
    error_log       /tmp/error.log info;
    location /server-status {
        stub_status     on;
        allow   127.0.0.1;
        deny    all;
    }
}

2 个答案:

答案 0 :(得分:2)

这不是错误。日志消息中的[info]表示此消息是信息性的。如果您不想看到这些消息,请将error_log指令中的日志级别设置为较不详细的级别,例如noticewarnerror。< / p>

答案 1 :(得分:0)

您可以禁用状态连接的HTTP keepalive,如果您访问它很少见:

的/ etc / nginx的/ /本地主机启用位点-

server {
    listen localhost;
    server_name nginx_status.localhost;
    access_log      /tmp/access.log;
    error_log       /tmp/error.log info;
    location /server-status {
        stub_status     on;
        keepalive_timeout 0;    # Disable HTTP keepalive
        allow   127.0.0.1;
        deny    all;
    }
}

感谢duskwuff。