Score:0

nginx force nginx to resolve dns - error 9#9 recv() (failed connection refused)

cn flag

I have a hostname like this: https://abc.xyz.com

I want to force resolve the dns everytime a request arrives, because if the dns of abc.xyz.com changes i want nginx to still be able to proxy to the site, therefore need to resolve the dns again.

Now i followed this post How to force nginx to resolve DNS (of a dynamic hostname) everytime when doing proxy_pass? and my configuration looks like this

server {
    ...
    resolver abc.xyz.com;
    set $backend "http://abc.xyz.com";
    proxy_pass $backend;
    ...
}

And i get this error [error] 9#9 recv() failed (111: connection refused) while resolving, resolver: <some-dns>:53

I don't understand what i'm doing wrong here, i guess it has something to do with the resolver. The only difference is that the guy in the post put dns there 127.0.0.1. I don't think i want to do that since dns/ip can change when i redploy my app and i saw you can give resolver a hostname but it doesn't work and i get this error.

Any help would be appreatiated!

Score:0
us flag

The resolver tells which DNS recursive server is used to resolve the domain name. You need to point it to your DNS server's IP address.

kevin avatar
cn flag
so if im understanding correcty, my application is not the dns server? and i need to figure out my dns-server's hostname (like dns-server.dns.com) or their dns( im assuming their dns doesnt change)?
us flag
You need to add your DNS resolver's IP address to the directive.
kevin avatar
cn flag
do you know where/how do I find that? sorry if its obvious and im stupid
us flag
You need to ask your hosting provider what are their DNS addresses.
kevin avatar
cn flag
i did, and it works, thanks!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.