Can Nginx resolves upstream server name given as SRV DNS records?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 07:42:43

问题


I just want to know if Nginx is able to resolve SRV DNS records when given as the upstream server address. It seems like it's not the case, but maybe there is a workaround if it can't do this out-of-the-box. Thx in advance.


回答1:


SRV records are not meant to be used like A(ddress) records. In theory it should be possible to hack nginx to resolve SRV records as well but the only advantage I could see is the 'weight' and 'priority' fields used in SRV records.

You can already use this feature in nginx config:

upstream backend  {
  server backend1.example.com weight=5;
  server backend2.example.com:8080;
  server unix:/tmp/backend3;
}

HttpUpstreamModule




回答2:


Free nginx does not support SRV records.

resolve and service keywords for upstream directive are not available in free nginx.

There are some free solutions available,

  • ngx_upstream_resolveMK
  • srv-router


来源:https://stackoverflow.com/questions/6769950/can-nginx-resolves-upstream-server-name-given-as-srv-dns-records

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!