Open millken opened 8 years ago
If DNS SRV record support can be added https://github.com/GUI/nginx-upstream-dynamic-servers/issues/3 , we may not need the dyups. When a new upstream server is added/removed, a request can be sent to update the DNS server (e.g.: Consul https://www.consul.io/ ) with DNS SRV record for IP, port, weight, etc. DNS server can even do health checks against the upstream (https://www.consul.io/docs/agent/dns.html ) so nginx will only get the "good" upstream servers.
@millken for now the module only check DNS changes of servers configured on conf file at startup time, there is no integration with modules like dyups. I think that can be done in the future.
@gfrankliu I don't know much about DNS SRV record, neither about nginx DNS queries internals, but I'm pretty sure that nginx does not support it, and since we use the core functions to discover the IPs, the module does not have support either.
Do you know a client code that support it? I can take a look and see how complex is to implement the support.
In nginx src/core/ngx_resolver.h, I see
#define NGX_RESOLVE_A 1
#define NGX_RESOLVE_CNAME 5
#define NGX_RESOLVE_PTR 12
#define NGX_RESOLVE_MX 15
#define NGX_RESOLVE_TXT 16
#if (NGX_HAVE_INET6)
#define NGX_RESOLVE_AAAA 28
#endif
#define NGX_RESOLVE_DNAME 39
I assume we can patch and add NGX_RESOLVE_SRV ?
Once we get the IP, port, weight information from the DNS resolver, we can store them for nginx to use, for upstream connection?
Here's one example, though using lua: https://github.com/vlipco/srv-router
Looks like nginx itself now supports SRV using "service" along with "resolve" in upstream server config: http://nginx.org/en/docs/http/ngx_http_upstream_module.html#service
Here is the new nginx-1.9.13/src/core/ngx_resolver.h
#define NGX_RESOLVE_A 1
#define NGX_RESOLVE_CNAME 5
#define NGX_RESOLVE_PTR 12
#define NGX_RESOLVE_MX 15
#define NGX_RESOLVE_TXT 16
#if (NGX_HAVE_INET6)
#define NGX_RESOLVE_AAAA 28
#endif
#define NGX_RESOLVE_SRV 33
#define NGX_RESOLVE_DNAME 39
I can see #define NGX_RESOLVE_SRV 33
is added.
https://github.com/yzprofile/ngx_http_dyups_module