My Plesk server main public IP on Centos 7 is 10.10.10.10 and there is also another dedicated IP assigned to a subscription domains e.g. 20.20.20.20. All websites and DNS settings are working fine, but PHP and other APIs showing server's main public IP instead of domains (Subscriptions) IP, so the requests from websites are not authorized on IP limited services and actually the output IP of websites requests are wrong. I am using this code to get the IP.
Thank you.
Thank you.
PHP:
<?php
// create a new cURL resource
$ch = curl_init ();
// set URL and other appropriate options
curl_setopt ($ch, CURLOPT_URL, "http://ipecho.net/plain");
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
// grab URL and pass it to the browser
$ip = curl_exec ($ch);
echo "The public ip for this server is: $ip";
// close cURL resource, and free up system resources
curl_close ($ch);
?>