6
反向代理在Connection reset by peer的情况下,upstream_response_time一直是30s,无论调了 proxy_connect_timeout proxy_read_timeout proxy_send_timeout 前后端的send_timeout,都没有效果,仍然是30秒。后端是php+nginx。这是bug? 这个时间由什么决定? 错误日志:
2017/01/08 21:03:25 [error] 22193#0: *148778376 recv() failed (104: Connection reset b
y peer) while reading response header from upstream, client: ***.***, server: ***.***, request: "POST /user/myInfo HTTP/1.1", upstream: "http://10.2.95.87:80/
user/myInfo", host: "***.***"
访问日志:
***.*** | 10/Jan/2017:03:58:24 +0800 | POST /user/myInfo?p=5&rid=-1&rcat=-1&uid=-1&net=0&screen=3&device=ngw8bxxtrgtsqzolzm9kk1mrx3jjnjdaz1t2cju8&refer=list%2Flol&sw=1920&sh=1080&ch=gouzai HTTP/1.1 | 502 | 271 | - | 8 | http://***.*** | Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E) | - | ***.*** | 30.000 | 30.000 | ixqiesd0.khyjxr | - | 10.2.95.87:80 | 502
访问日志格式:
"$http_cdn_src_ip | $time_local | $request | $status | $body_bytes_sent | "
"$request_body | $content_length | $http_referer | $http_user_agent | "
"$http_x_forwarded_for | $remote_addr | $upstream_response_time | $request_time | $http_x_trace_code | $upstream_cache_status | $upstream_addr | $upstream_status";
nginx的相关配置:
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_send_timeout 5;
reset_timedout_connection on;
send_timeout 30s;
后端nginx的日志:
***.*** | 10/Jan/2017:03:58:24 +0800 | POST /user/myInfo?p=5&rid=-1&rcat=-1&uid=-1&net=0&screen=3&device=ngw8bxxtrgtsqzolzm9kk1mrx3jjnjdaz1t2cju8&refer=list%2Flol&sw=1920&sh=1080&ch=gouzai HTTP/1.1 | 408 | 0 | - | 8 | ***.*** | Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E) | ***.*** | 10.1.0.1 | - | 30.000 | ixqiesd0.khyjxr | - | -
前端和后端tengine版本都是一样的,配置基本一样,从日志来看是nginx等待后端php-fpm时间是30秒。