我们观察到,如果我们重新加载nginx配置,则正在进行的HTTP 1.1请求成功完成但没有Connection:close会导致客户端尝试重新使用已关闭的连接.通过使用两个请求进行卷曲可以轻松地再现该行为,其中在第一个请求期间,我们通过HUP信号重新加载nginx配置.
curl -v -H "Host: foo.bar.host" "http://proxy1:4080/do-it-takes-time-and-reload-is-called" "http://proxy1:4080/do-it" * Connected to proxy1 (xx.xxx.xxx.xxx) port 4080 (#0) >GET /do-it-takes-time-and-reload-is-called HTTP/1.1 > Host: foo.bar.host > User-Agent: curl/7.54.0 > Accept: */*虽然这个长期存在的请求是在战斗中我们做了一个kill -HUP来重新加载配置但是注意响应如何表示Connection:keep-alive所以curl试图重新使用连接但服务器不想要任何这样的请求被拒绝(RST)
* Found bundle for host proxy1 0x7f96e980f510 [can pipeline] * Re-using existing connection! (#0) with host proxy1 * Connected to proxy1 (xx.xxx.xxx.xxx) port 4080 (#0) > GET /do-it HTTP/1.1 > Host: foo.bar.host > User-Agent: curl/7.54.0 > Accept: */* > * Connection died, retrying a fresh connect * Closing connection 0 * Issue another request to this URL: ..那么有没有办法让nginx用一个Connection礼貌地结束对话:在配置重新加载时关闭?