Page 1 of 1

Incorrect IP address PHP

Posted: Fri Apr 07, 2017 6:02 pm
by Pilovali
Heya,

If I use the following code:

Code: Select all

<?php
echo $_SERVER['REMOTE_ADDR'];
?>
Then I'm seeing the IP address of my webserver. However, HTTP_X_REAL_IP and HTTP_X_FORWARDED_FOR does show the correct IP address.
I am not going to replace all my scripts with that. I just want it to give the correct IP via REMOTE_ADDR.

It's a clean installation on Ubuntu 16.04 minimal. All latests updates and PHP 7.

Does anybody knows how to fix this?

Re: Incorrect IP address PHP

Posted: Fri Apr 07, 2017 6:41 pm
by Pilovali
I fixed it myself. For future references:

Run the following:

Code: Select all

wget https://raw.githubusercontent.com/serghey-rodin/vesta/master/upd/switch_rpath.sh
chmod +x switch_rpath.sh
./switch_rpath.sh
Source:
viewtopic.php?t=13817#p56361
viewtopic.php?f=10&t=13499&p=54963&hili ... .sh#p54963