weibocom / nginx-upsync-module

For http protocol. nginx-upsync-module, sync upstreams from consul or etcd and so on, dynamiclly modify backend-servers attributes(weight, max_fails, down...), needn't reload nginx
1.82k stars 391 forks source link

consul service discovery #51

Closed gfrankliu closed 8 years ago

gfrankliu commented 8 years ago

upsync currently uses kv from consul. Is it possible to enhance it to use consul's service discovery? A service can map to one nginx upstream. When server registers/unregisters a service, it can be added/removed from the nginx upstream. Consul supports service health check, so if a server fails health check by consul, it will be removed from the service, and nginx won't even need to do its own health checks.

gfrankliu commented 8 years ago

@luxuan @imiskolee 是否再考虑一下。Consul的Service Discovery还是有不少优点的。它自己可以检查健康性。DNS SRV看来好像专为nginx upstream配置设计的 :)

gfrankliu commented 8 years ago

Can you make "upsync" talk to consul service catalog endpoint to get the upstream server IP and ports? The other information, such as weight=1 max_fails=2 fail_timeout=10 down=0 backup=0, can use the consul service tags. When we use cloud server upstream autoscale up and down, we will need a separate task to clean up consul kv, but it will be easier for consul service where health check and auto removal are supported.