小编Jo *_*gum的帖子

当重新加载nginx配置时,在没有Connection:close的情况下,在完成后关闭http 1.1请求

我们观察到,如果我们重新加载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: */*

< HTTP/1.1 200 OK
< Server: nginx/1....
< Date: ..
< Content-Type: application/json;charset=utf-8
< Content-Length: 160
< Connection: keep-alive
< Vary: Accept-Encoding
< Keep-Alive: timeout=10, max=360
* Connection #0 to host proxy left intact
{ "foo":"bar"}
Run Code Online (Sandbox Code Playgroud)

虽然这个长期存在的请求是在战斗中我们做了一个kill -HUP来重新加载配置但是注意响应如何表示Connection:keep-alive所以curl试图重新使用连接但服务器不想要任何这样的请求被拒绝(RST)

* Found bundle for host proxy1 0x7f96e980f510 [can pipeline]
* Re-using existing connection! …
Run Code Online (Sandbox Code Playgroud)

nginx

5
推荐指数
0
解决办法
145
查看次数

标签 统计

nginx ×1