Obtaining the connecting clients IP address (Real IP) in PHP:

PHP is a general-purpose scripting language that is especially suited to server-side web development, in which case PHP generally runs on a web server. Any PHP code in a requested file is executed by the PHP runtime, usually to create dynamic web page content or dynamic images used on websites or elsewhere.

This is not required if your webserver is configured to retrieve the clients IP

PHP Method:

PHP supports the X-Real-IP header through the definitions within the .PHP web files. The definitions are usually entered in the web pages configuration files. To enable X-Real-IP IP forwarding for the retrieval of the connecting users IP address.

Edit a PHP file that is opened every-time your website is visited, configuration files are usually opened each time a user visits. These are often named: config.php, global.php or defines.php

  1. Open one the PHP file in your favourite text editor, the file can also be updated over FTP / SCP / SFTP or SSH:
nano /var/www/wordpress_blog/wp-config.php
  1. At the top of the configuration file after <?php, add:
if(isset($_SERVER['HTTP_X_REAL_IP'])){
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];
}

This configures your script to look for the X-Real-IP header, and uses that as the clients IP address instead of your proxy IP.

If successful the IP of users connecting through the proxy service should be visible in the script you are using on your website.

More Information

More information on the X-Real-IP header can be found here. More information on the PHP can be found on the project website.