Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx转发consul问题 #250

Open
arrow2012 opened this issue Apr 27, 2019 · 6 comments
Open

nginx转发consul问题 #250

arrow2012 opened this issue Apr 27, 2019 · 6 comments

Comments

@arrow2012
Copy link

arrow2012 commented Apr 27, 2019

upstream配置如下:

    upstream infra-service {
    least_conn;
    upsync 192.168.20.103:8500/v1/kv/upstreams/infra-service upsync_timeout=6m 
    upsync_interval=2000ms upsync_type=consul strong_dependency=off;
    upsync_dump_path /data/app/openresty/nginx/conf/conf.d/infra-service.ini;
    include /data/app/openresty/nginx/conf/conf.d/infra-service.ini;
    keepalive 16;

}

问题1: 192.168.20.103:8500 是consul集群的其中一个节点,现在consul集群有3个节点,upstream里面的upsync能否配置3个consul的地址?

问题2: 如果不能配置多个consul地址,我只能用nginx本身做转发consul

     upstream consul-server{
  server 192.168.20.103:8500;
   server 192.168.20.105:8500;
   server 192.168.20.109:8500;
}

server {
    listen 80;
    server_name consul-nginx.test.in;
    access_log /data/logs/nginx/consul.log log_json;
    location / {
    proxy_connect_timeout 10s;
    proxy_pass http://consul-server;
    }
}

然后业务的upstream配置
upsync consul-nginx.test.in/v1/kv/upstreams/infra-service upsync_timeout=6m
upsync_interval=2000ms upsync_type=consul strong_dependency=off;

上面这种配置nginx的errlog 会经常报错502
2019/04/27 14:31:02 [error] 9100#9100: *6511083 no live upstreams while connecting to upstream, client: 192.168.20.110, server: consul-nginx.test.in, request: "GET /v1/kv/upstreams/infra-service?recurse&index=543011 HTTP/1.0", upstream: "http://consul-server/v1/kv/upstreams/infra-service?recurse&index=543011", host: "consul-nginx.test.in"
2019/04/27 14:31:02 [error] 9099#9099: upsync_consul_parse_init: recv upstream "infra-service" error; http_status: 502

@arrow2012
Copy link
Author

错误类型 如同这个问题: #221 (comment)

@wanglin90
Copy link

问题1: 192.168.20.103:8500 是consul集群的其中一个节点,现在consul集群有3个节点,upstream里面的upsync能否配置3个consul的地址?


这个问题,怎么解决的呢?

@vqiu
Copy link

vqiu commented Aug 19, 2019 via email

@bale836
Copy link

bale836 commented Sep 19, 2019

问题1: 192.168.20.103:8500 是consul集群的其中一个节点,现在consul集群有3个节点,upstream里面的upsync能否配置3个consul的地址?

这个问题,怎么解决的呢?

个人理解:
在consul集群模式下,业务只访问本地client模式的consul就可以了,比如:127.0.0.1:8500
不应该访问consul server模式的节点(除非server模式本地的服务,也是以本地模式访问)

@itcam
Copy link

itcam commented Nov 12, 2019

问题1: 192.168.20.103:8500 是consul集群的其中一个节点,现在consul集群有3个节点,upstream里面的upsync能否配置3个consul的地址?
这个问题,怎么解决的呢?

个人理解:
在consul集群模式下,业务只访问本地client模式的consul就可以了,比如:127.0.0.1:8500
不应该访问consul server模式的节点(除非server模式本地的服务,也是以本地模式访问)

还是一个问题啊,节点IP 不能是单点啊,client 如果出现故障,还是会影响啊,问题的重点不在client模式还是server模式,重点是要能连接多个consul节点

@hanggegege
Copy link

upstream配置如下:

    upstream infra-service {
    least_conn;
    upsync 192.168.20.103:8500/v1/kv/upstreams/infra-service upsync_timeout=6m 
    upsync_interval=2000ms upsync_type=consul strong_dependency=off;
    upsync_dump_path /data/app/openresty/nginx/conf/conf.d/infra-service.ini;
    include /data/app/openresty/nginx/conf/conf.d/infra-service.ini;
    keepalive 16;

}

问题1: 192.168.20.103:8500 是consul集群的其中一个节点,现在consul集群有3个节点,upstream里面的upsync能否配置3个consul的地址?

问题2: 如果不能配置多个consul地址,我只能用nginx本身做转发consul

     upstream consul-server{
  server 192.168.20.103:8500;
   server 192.168.20.105:8500;
   server 192.168.20.109:8500;
}

server {
    listen 80;
    server_name consul-nginx.test.in;
    access_log /data/logs/nginx/consul.log log_json;
    location / {
    proxy_connect_timeout 10s;
    proxy_pass http://consul-server;
    }
}

然后业务的upstream配置 upsync consul-nginx.test.in/v1/kv/upstreams/infra-service upsync_timeout=6m upsync_interval=2000ms upsync_type=consul strong_dependency=off;

上面这种配置nginx的errlog 会经常报错502 2019/04/27 14:31:02 [error] 9100#9100: *6511083 no live upstreams while connecting to upstream, client: 192.168.20.110, server: consul-nginx.test.in, request: "GET /v1/kv/upstreams/infra-service?recurse&index=543011 HTTP/1.0", upstream: "http://consul-server/v1/kv/upstreams/infra-service?recurse&index=543011", host: "consul-nginx.test.in" 2019/04/27 14:31:02 [error] 9099#9099: upsync_consul_parse_init: recv upstream "infra-service" error; http_status: 502

你好 问题解决了吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants