proxy_read_timeout是控制proxy后端服務器之間的超時時間,keepalive_timeout是控制客戶端和nginx之間的超時時間,但如果proxy_read_timeout大於keepalive_timeout是不是意味着nginx和客戶端斷開了,nginx還和后端服務器在保持着聯系。
Defines a timeout for reading a response from the proxied server. The timeout is set only between two successive read operations, not for the transmission of the whole response. If the proxied server does not transmit anything within this time, the connection is closed.
Sets a timeout during which an idle keepalive connection to an upstream server will stay open.
兩個 timeout 不是同時生效的。keepalive_timeout 用於閑置的連接(沒有正在進行數據傳輸的連接),proxy_read_timeout 用於從 upstream 讀取返回數據時,這時連接並不是閑置的。
proxy_read_timeout大於keepalive_timeout 意味着 upstream 正在返回數據時,可以多等一些時間 (proxy_read_timeout) ,傳輸完成之后,經過一段不太長的時間(keepalive_timeout),如果沒有新的請求需要復用這個連接,這個連接將被關閉。