• 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

Forwarded to devs Plesk Obsidian PHP $_SERVER['SERVER_ADDR'] returns 127.0.0.1

danami

Silver Pleskian
TITLE:
Plesk Obsidian PHP $_SERVER['SERVER_ADDR'] returns 127.0.0.1
PRODUCT, VERSION, OPERATING SYSTEM, ARCHITECTURE:
Product version: Plesk Obsidian 18.0.20.0
OS version: CloudLinux 7.7 x86_64
Build date: 2019/10/18 18:00
Revision: e02f419139a3325041284ef4acc15b1fbbd9b2c4
PROBLEM DESCRIPTION:
Plesk Obsidian 18.0.20.0 the panel PHP is returning '127.0.0.1' for the $_SERVER['SERVER_ADDR'] when the user accesses the panel using the servers IP address:

Example:
https://serverip:8443 returns 127.0.0.1
https://hostname:8443 returns the proper IP address.
STEPS TO REPRODUCE:
Create the file `/usr/local/psa/admin/htdocs/test.php` with the following contents:

Code:
<?php
echo $_SERVER['SERVER_ADDR'];
?>

Now access the file in the panel using https://serverip:8443/test.php and it will output '127.0.0.1' not the servers IP address.​
ACTUAL RESULT:
127.0.0.1​
EXPECTED RESULT:
The servers IP address should be returned properly regardless of using the hostname or IP address.​
ANY ADDITIONAL INFORMATION:
This causes problems for plesk extension developers who rely on this on being correct.
YOUR EXPECTATIONS FROM PLESK SERVICE TEAM:
Confirm bug
 
Last edited:
In Obsidian there is a new feature: access Plesk with 443 port. This feature is optional, but you likely use it.

In this case, you open https://domain.tld/test.php which is actually one more reverse proxy to http://127.0.0.1:8880/test.php and you receive 127.0.0.1 in the server address variable.

If you need a server IP address, I would recommend finding a more reliable way for it, at least we don't use $_SERVER['SERVER_ADDR']
 
IgnorG then why does $_SERVER['SERVER_ADDR'] work fine as on Plesk Obsidian on Centos? Like I said only CloudLinux is affected. Also I'm accessing the panel using https://serverip:8443/test.php NOT https://domain.tld/test.php . (notice that I have the :8443 port in there). I'm talking about the Plesk PHP used by Plesk extensions not the PHP for websites used by the server.
 
From developer:

However, we do not modify this variable. We cannot consider it as a bug in Plesk.
As I said the variable is not reliable and not recommended for usage in extensions.
 
Back
Top