I have an infrastructure where all requests made by internal subnets have to pass through a server in the "open to the world" subnet, where my NAT instance is (I'm using AWS).
I want to create a host name to be used internally, that is, any requests made by the internal instances to example.com should be redirected by the NAT instance to some specific internal instance.
I already have haproxy in my NAT instance. It is forwarding incoming traffic to example.com to some internal ip address. If I change an internal instance's /etc/hosts
with:
172.31.10.123 example.com
(where 172.31.10.123 is the ip address for the NAT instance)
the requests from such internal instance is correctly redirected. The problem is I would have to modify the /etc/hosts
file to every instance and I don't want that.
So, since all traffic to the web should pass through the NAT instance, is it possible to check if a host destination is example.com and redirect it to my specific internal instance's ip address?