The setup is : Two applications are hosted on same linux server using vhost entries in apache configuration. say :
and
Both of them have a functionality where they do server side http request to a third url (using php cURL / file_get_contents) :
Now there is a host entry of an in the hosts file '/etc/hosts'
xx.xx.xx.xx apis.example.com
This is only intended for greatapp.example.com code, and not for superapp.example.com.
How to configure the server such that greatapps.example.com uses the host entry, but superapp.example.com uses the public ip of apis.example.com
It cannot be done directly: host name space is global per host.
You could run one of the apaches in a virtual machine with a different /etc/hosts
file.