疑犯追踪
Nginx upstream健康检查:后端挂了自动踢出局_我的网站

A |
一键部署OpenClaw
单台后端出问题时,如果Nginx还继续把请求发过去,用户看到的不是502就是超时。upstream配置里的max_fails和fail_timeout可以让Nginx自动把失败节点暂时下线,保证正常请求不受影响。 Paris, Oct 20 (UNI) France has carried out an operation to return French nationals, 40 children and 15 women, from camps in Syria holding family members of Islamic State terrorist organization, the French foreign ministry said on Thursday.
"Today, France conducted a new operation to return French citizens who were in camps in northeastern Syria to the national territory. This operation allowed the return of 40 children and 15 women," the ministry said in a statement.
Minors were handed over to child care services, while adults were transferred to the competent judicial authorities, the ministry added.
Up to 70,000 refugees, mostly women and children from the families of Islamic State jihadists, reportedly live in a camp in the northeast of the Syrian territory controlled by the Arab-Kurdish detachments of the Syrian Democratic Forces and the United States. Among the camp's residents are not only Syrians, but also citizens of other countries, who travelled to Syria to join the Islamic State.
UNI/SPUTNIK GNK。
这是被动健康检查,不需要商业模块。Nginx在指定时间内检测到多次失败,就把节点标记为不可用,等fail_timeout过后再尝试恢复。
upstream backend {
server 192.168.1.11:8080 weight=5 max_fails=3 fail_timeout=30s;
server 192.168.1.12:8080 weight=5 max_fails=3 fail_timeout=30s;
server 192.168.1.13:8080 backup;
}
server {
location / {
proxy_pass http://backend;
proxy_next_upstream error timeout http_500 http_502 http_503;
proxy_connect_timeout 5s;
}
} proxy_next_upstream很关键,它告诉Nginx在什么情况下把请求换一台后端重试。但只建议对幂等请求开启GET/HEAD重试,POST请求重复提交可能带来业务风险。
如果有条件,建议用Nginx Plus的主动健康检查模块,会周期性向后端发探测请求,比被动检测更早发现问题。免费版用被动方案也基本够用了。

B | 数据来源:Nginx官方文档 ngx_http_upstream_module(max_fails / fail_timeout / proxy_next_upstream)
申请创业报道,分享创业好点子。点击此处,共同探讨创业新机遇!。
Current article:http://uha.qixicuorenchouzuan.buzz/list_swsqs5/7kv.pptx
Published on:05:50:17




