• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion
  • Inviting everyone to the UX test of a new security feature in the WP Toolkit
    For WordPress site owners, threats posed by hackers are ever-present. Because of this, we are developing a new security feature for the WP Toolkit. If the topic of WordPress website security is relevant to you, we would be grateful if you could share your experience and help us test the usability of this feature. We invite you to join us for a 1-hour online session via Google Meet. Select a convenient meeting time with our friendly UX staff here.

Resolved Plesk returns server's IP instead of subscription's IP

eArmin

New Pleskian
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.

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);
?>
 
The behavior is correct, because outgoing traffic uses the default interface and the default ip address. Maybe one of these solutions can help:

Solution 1:
$ip = "xxx.xxx.xxx.xxx"; // enter custom ip
curl_setopt($ch, CURLOPT_HTTPHEADER, ["REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip"]);

Solution 2:
$interfacename = 'eth0'; // enter the interface name that is linked to the ip that you want to use
curl_setopt($ch, CURLOPT_INTERFACE, $interfacename);
 
The behavior is correct, because outgoing traffic uses the default interface and the default ip address. Maybe one of these solutions can help:

Solution 1:
$ip = "xxx.xxx.xxx.xxx"; // enter custom ip
curl_setopt($ch, CURLOPT_HTTPHEADER, ["REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip"]);

Solution 2:
$interfacename = 'eth0'; // enter the interface name that is linked to the ip that you want to use
curl_setopt($ch, CURLOPT_INTERFACE, $interfacename);

That's great. Thank you so much, Solution 2 worked for me.

Now I worry about the correct IP and reverse DNS configuration for Mail Services for domains with dedicated IPs too! Actually, I have posted a topic in Hetzner's forums. but since it may be offtopic I will open a new thread later.
 
Back
Top