nginx 连接超时和客户端关闭连接问题

Nit*_*har 23 nginx timeout keepalive

我在 AWS 上运行了这台 nginx 服务器,直到最近,当几个用户开始抱怨该网站在尝试访问 10 次后才打开,它一直运行良好。

我从来没有能够从我身边重现这个问题。我正在使用 google 的 dns,即 8.8.8.8,当我为其中一个用户更改相同的 dns 时,该站点运行良好。现在这可能是原因,也可能只是巧合。

我在错误日志中发现了这个 -

2014/05/29 13:46:15 [info] 6940#0: *150649 client timed out (110: Connection timed out) while waiting for request, client: xx.xxx.xxx.xx, server: 0.0.0.0:80
2014/05/29 13:46:20 [info] 6940#0: *150670 client closed connection while waiting for request, client: xx.xxx.xxx.xx, server: 0.0.0.0:80
2014/05/29 13:46:20 [info] 6940#0: *150653 client closed connection while waiting for request, client: xx.xxx.xxx.xx, server: 0.0.0.0:80
2014/05/29 13:46:20 [info] 6940#0: *150652 client closed connection while waiting for request, client: xx.xxx.xxx.xx, server: 0.0.0.0:80
Run Code Online (Sandbox Code Playgroud)

有些地方甚至是这样——

2014/05/29 13:46:53 [info] 6940#0: *150665 client closed connection while waiting for request, client: xx.xxx.xxx.xx, server: 0.0.0.0:80
2014/05/29 13:46:53 [info] 6940#0: *150660 client xx.xxx.xxx.xx closed keepalive connection
Run Code Online (Sandbox Code Playgroud)

注意- 已为客户端 IP 放置了 xx.xxx.xxx.xx

这是 nginx 配置 -

server {
    listen       80;
    server_name  somedomain.com  www.somedomain.com;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    root        /var/www/somedomain/current/app/webroot;
    index       index.php index.html index.htm;

    ... couple of location rules ...
}
Run Code Online (Sandbox Code Playgroud)

我真的很感激任何帮助。

谢谢

Lin*_*ong 6

根据您从 Nginx 提供的日志,您的服务器和用户之间的连接似乎不稳定或缓慢。请尝试traceroute从您的服务器访问您的客户端 IP 地址或他/她的网关。还有,ping你的客户端IP地址多长时间看丢包率和响应时间。MTU 可能是此问题的另一个来源。测试您是否可以使用 MTU=1500 (Mac: ping -D -s 1472 xx.xx.xx.xx)访问您的客户端。

BTW:如果你的服务器或客户端在中国,这个问题通常不是你的错。众所周知,GFW 会在边界之间随机丢弃数据包,从而故意降低国际连接质量。


Pet*_*ter 0

正如该评论中推测的那样,这可能是用户错误,他们正在关闭连接(无论是有意还是无意)。尝试可靠地重现问题。排除它发生在其他地方的可能性,如果只是那个位置,他们将需要自行排除故障。尝试使用不同的浏览器/计算机,然后测试网络可靠性。