nginx报错no live upstreams while connecting to upstream

前端请求后端服务时一直报错 502 bad gateway,查看后端的服务是正常启动的。后来又查看nginx的错误日志,发现请求后端接口时 nginx报错no live upstreams while connecting to upstream,查看该错误的解释可以得到的结果是upstream中没有可以提供服务的server ,即nginx已经发现不了存活的后端了,但是,我直接访问后端的server确是可以使用的,证明server端可用.
最后查找文档,发现问题出现在业务上要求保持会话,但是nginx到后端并没有保持会话,那么,nginx当然就找不到后端可用服务,就会报no live upstream.具体详细原理解释参考下面文档 .
参考文档
修改nginx的配置

upstream xxxxxxx {
    server 172.17.192.98:8087 max_fails=3 fail_timeout=5s weight=1;
    server 172.17.192.99:8087 max_fails=3 fail_timeout=5s weight=1;
    keepalive 256;     //添加keepalive配置
}
  location ^~ /xxxxxx/ {
    ...
    proxy_http_version 1.1;
    proxy_set_header Connection "";     //规制强制指定使用1.1协议
    ...
}

Supongo que te gusta

Origin blog.csdn.net/sunzheng176/article/details/121573917
Recomendado
Clasificación