Proxy server Fix

Just worked out (yes – I’m that slow..) that all I needed to so was change the $_SERVER environment variable so that I can properly record the IP address of incoming requests.

Since I set up the proxy server a while ago to split out the websites onto different virtual machines, all my site stats recorded the proxy server as the originating site of the web page requests. Which was sort of true – everything was coming via the proxy server – but I do like to know where in the world people are coming from looking at this site.

For the record the fix just required this entry in the wp-config.php file. I basically rewrite the REMOTE_ADDR variable to look into where the proxy has forwarded it from.

/* By MGV on 20200607 - New entry to handle proxy server
     - this will allow us to see the real IP of the client
     - rather than the proxy server IP */

$_SERVER['REMOTE_ADDR']=$_SERVER['HTTP_X_FORWARDED_FOR'] ;

I guess this could blow up if the site goes to a different server, but for now, its getting the right Internet address for site stats.