【问题标题】:No live upstreams while connecting to upstream, but upsteam is OK连接上游时没有实时上游,但上游是可以的
【发布时间】:2016-05-08 21:15:31
【问题描述】:

我对 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,我得到HTTP request sent, awaiting response... 200 OK。我还验证了端口 6006 正在使用 netstat 进行侦听,并且正常。

但是当我向 NGINX 文件服务器发送请求时,我收到以下错误:

连接上游时没有实时上游,客户端:..,请求:“POST /files/save/2 HTTP/1.1,上游:“https://files_1/save

但是上游没问题。有什么问题?

【问题讨论】:

  • 这是唯一的错误信息吗?
  • @RichardSmith:是的。在此之前,在error.log 我得到以下行:a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000025...
  • 您是否设法解决了这个问题?我在尝试将 Nginx 用作 Java 服务器的代理服务器时遇到了同样的问题。
  • 今天居然遇到了类似的问题。甚至没有改变任何东西。并且设置已经运行了几个月没有问题。直到今天。

标签: nginx


【解决方案1】:

在定义upstream时,Nginx 会处理目标服务器以及可以启动或关闭的东西。 Nginx 根据fail_timeout(默认10s)和max_fails(默认1)决定你的上游是否关闭

因此,如果您有一些慢速请求超时,Nginx 可以确定您的上游服务器已关闭,并且由于您只有一个,因此整个上游实际上已关闭,Nginx 报告no live upstreams。在这里更好地解释:

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 ;
}

【讨论】:

【解决方案2】:

我遇到了同样的错误no live upstreams while connecting to upstream

我的与 SSL 相关:添加 proxy_ssl_server_name on 解决了它。

location / {
    proxy_ssl_server_name on;
    proxy_pass https://my_upstream;
  }

【讨论】:

  • 你是如何发现它与 SSL 相关的?有什么具体错误吗?
  • 我什么都不记得了
猜你喜欢
  • 1970-01-01
  • 2022-11-16
  • 1970-01-01
  • 1970-01-01
  • 2012-10-24
  • 1970-01-01
  • 2021-06-01
  • 2018-03-18
  • 2019-05-31
相关资源
最近更新 更多