ANS Documentation

Improve This Doc
  • Cloud
  • Domains and DNS management
  • Backup and High Availability
  • eCommerce Stacks
  • Security
  • Email
  • Monitoring and usage management
  • Networking
  • Operating systems
  • Webcelerator
    • Introduction
    • Getting started
    • Configuring SSL
    • Extracting Client IP
    • How to Purge the Webcelerator Cache
    • HTTP Error Codes
    • Monitoring
    • Going Live
    • Queue System
  • MyUKFast
  • Home >
  • Webcelerator >
  • Extracting Client IP

Extracting Client IP¶

Since all requests to your web servers will now be coming directly from the Webcelerator, your log files on your server will show that every request comes from the same IP address. If you’re using something like Google Analytics for visitor stats, this shouldn’t matter. If you’re using log file processing tools like AWStats or Webalizer, you won’t be able to extract meaningful data from your logs anymore.

If you are also extracting the client’s IP address to use in your website or application, e.g. using $_SERVER['REMOTE_ADDR'] in PHP, then the IP reported will also now be the Webcelerator’s IP.

To solve these problems, the Webcelerator will place the client’s IP address into an X-Forwarded-For HTTP header.

We can make your web server log this as the client’s IP instead by applying a platform-dependent fix. If you need this please speak with us and we can apply the appropriate fixes to your solution. (Including mod_rpaf for Apache, an ISAPI filter for IIS, and the HTTPRealIPModule for NGINX).

PHP Overwrite¶

For your web application and code you should begin inspecting the X-Forwarded-For header instead of the IP where the request came from. Here’s some example PHP code you could use to overwrite the REMOTE_ADDR variable.

if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}

Also note that if you have other devices in your solution that already forward on the HTTP_X_FORWARDED_FOR header then the Webcelerator will add these to the header so you receive a comma separated list of IPs.

To always extract the client IP you would then need to apply to the above example code.

$_SERVER['REMOTE_ADDR'] = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$_SERVER['REMOTE_ADDR'] = trim($_SERVER['REMOTE_ADDR'][0]);

Next Article > How to Purge the Webcelerator Cache

  • Useful Links
  • SMB
  • Enterprise
  • Channel
  • Public Sector
  • ANS Data Centres
  • About ANS
  • Careers
  • Blog
  • Get in touch
  •  
  • Sales 0800 458 4545
  • Support 0800 230 0032
  • Get in touch

© ANS Group Limited | Terms and Conditions | Corporate Guidance | Sitemap
ANS Group Limited, registered in England and Wales, company registration number 03176761, registered office 1 Archway, Birley Fields, Manchester M15 5QJ