错误信息:upstream prematurely closed connection while reading response header from upstream,
错误现象:nginx正常接收请求,正常调用后台接口,正常获取接口返回信息,但是请求已经中断
解决方案:
location / {
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
}
原因:
nginx默认采用http1.0从后端获取响应返还给客户端,但是HTTP1.0不支持keepalive;
proxy_set_header Connection默认close:通知后端服务器主动关闭连接,这样会导致任何一个客户端的请求都在后端服务器上产生了一个TIME-WAIT状态的连接