Friday, May 29, 2015

Resolving domain names differently for different services



Some time ago we had an issue with our network infrastructure and php with curl.




Our Network infrastructure is fairly simple.



LoadBalancer/Firewall => 5 servers



The Domainname of our website is set to the ip of the Loadbalancer, of course. But calling curl from one of the servers did result in a timeout. It appears that a server could not call for its own domain it is serving. So we had to set the domains via /etc/hosts to the sever itself.



But now We have implemented a Varnish in front of the Loadbalancer, which we want to automatically purge, once a change on a page happens. So now we need to call the domain www.example.com/url_to_purge. Sadly this call what be resolved to the server itself instead of the varnish, because of the /etc/hosts entries.



So now I am wondering, if you could resolve domain names differently for different services :)



Answer



To answer the question, the only way I am aware of - but never seen used - is via the RES_NAMESERVER environment variable.



To answer your problem, I agree with David Schwartz that you need to remove the /etc/hosts entries because it will only cause you problems. Change your approach to either change the firewall or go directly to a backend host.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...