Nginx Http运行状况检查失败

时间:2018-12-05 15:17:18

标签: nginx

在使用Consul和Nginx Plus设置系统以在几个Centos 7 VM上进行测试的同时,我设法将Nginx手动配置为两个不同服务的负载均衡器。 每个服务都是一个简单的Node.js http服务器,它具有唯一的侦听端口,并返回“ Hello World from Service = X,port = Y”。我在每台计算机上运行三个服务实例(总共六个)。

一切正常,负载均衡正常运行。 但是现在我为一个上游添加了health_check,但是在Nginx error.log中遇到了一个错误:

2018/12/05 16:52:20 [error] 17542#17542: *784 no live upstreams while connecting to upstream, client: 172.1.2.3, server: , request: "GET /ua HTTP/1.1", upstream: "http://useradmin/ua", host: "10.1.2.3"

nginx.conf文件如下所示:

user nginx;

events {
    worker_connections  1024;
}

http {
    #
    # DNS resolving using Consul
    resolver localhost:8600 valid=30s;
    resolver_timeout 2s;

    # ...
    # Configuration of the server group
    upstream useradmin {
    zone useradmin 64k;

        server app1.node.consul:8080 resolve;
        server app1.node.consul:8081 resolve;
        server app2.node.consul:8080 resolve;
    }
    upstream search {
        zone search 64k;

        server app1.node.consul:8180 resolve;
        server app2.node.consul:8180 resolve;
        server app2.node.consul:8181 resolve;
    }

    match hello {
        status 200-399;
        header Content-Type = text/html;
        body ~ "Hello";
    }

    server {
        listen 80;

        # Location that proxies requests to the upstream group
        location /ua {
            proxy_pass http://useradmin;
            health_check interval=10 fails=3 passes=2 match=hello;
        }

        location /search {
            proxy_pass http://search;
#            health_check interval=5s match=hello;
        }
    }
}

我已经阅读了所有有关健康检查的Nginx文档,但不知道可能出了什么问题。我想念什么吗?

谢谢!

0 个答案:

没有答案