我对 NGINX 有一个非常奇怪的问题。
我有以下内容upstream.conf
文件,具有以下上游:
upstream files_1 {
least_conn;
check interval=5000 rise=3 fall=3 timeout=120 type=ssl_hello;
server mymachine:6006 ;
}
在locations.conf中:
location ~ "^/files(?<command>.+)/[0123]" {
rewrite ^ $command break;
proxy_pass https://files_1 ;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
在 /etc/hosts 中:
127.0.0.1 localhost mymachine
当我做:wget https://mynachine:6006/alive --no-check-certificate
, I get HTTP request sent, awaiting response... 200 OK
。我还用netstat验证了端口6006正在监听,并且没问题。
但是当我向 NGINX 文件服务器发送请求时,出现以下错误:
连接到上游时没有实时上游,客户端:..,请求:“POST /files/save/2 HTTP/1.1,上游:”https://files_1/保存 https://files_1/save"
但上游没问题。问题是什么?
定义时upstream
Nginx 处理目标服务器以及可能处于启动或关闭状态的服务器。 Nginx 根据以下条件决定您的上游是否已关闭fail_timeout
(默认 10 秒)和max_fails
(默认 1)
因此,如果你有几个超时的慢速请求,Nginx 可以确定你的上游服务器已关闭,并且因为你只有一个,所以整个上游服务器实际上已关闭,并且 Nginx 报告no live upstreams
。这里更好地解释:
https://docs.nginx.com/nginx/admin-guide/load-balancer/http-health-check/ https://docs.nginx.com/nginx/admin-guide/load-balancer/http-health-check/
我遇到了类似的问题,您可以防止覆盖这些设置。
例如:
upstream files_1 {
least_conn;
check interval=5000 rise=3 fall=3 timeout=120 type=ssl_hello max_fails=0;
server mymachine:6006 ;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)