It's not quite clear what you're exactly asking about.
I understand you are moving from the setup where you have applications on two different servers, ie. https://myserver1.com and https://myserver2.com, to the setup where both applications are on the same server?
But how the applications are calling each other? Do they still use the addresses https://myserver1.com and https://myserver2.com (only the domains myserver1.com and myserver2.com now point to the same machine)? Or are they using a common http://myserver.com ? Or are they using https://localhost when calling each other?
Except the last case, the DNS lookups must still be performed. After the DNS lookups the server will know that the IP addresses for domains are assigned to the same machine, so the actual communication between applications will occur inside the machine. But first the DNS server must be consulted anyway.
localhost
is a special case because that name is by default listed in the /etc/hosts
file together with the IP address 127.0.0.1
. Names that are in the /etc/hosts
file are immediately translated to corresponding IP addresses, without the need to perform DNS lookup.
So if you want to avoid the DNS lookup for myserver1.com and myserver2.com (or single myserver.com if this is the case) you can put these names into /etc/hosts
file with the corresponding IP addresses.