錯誤信息: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狀態的連接