热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

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

如何解决《当重新加载nginx配置时,在没有Connection:close的情况下,在完成后关闭http1.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: */*



虽然这个长期存在的请求是在战斗中我们做了一个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礼貌地结束对话:在配置重新加载时关闭?


推荐阅读
author-avatar
yvli心语
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有