Overriding the GEO IP header

Get compliant today in the European Union, United States, Canada, United Kingdom, Australia, Brazil & South Africa with the only Privacy Suite for WordPress that offers a fully-featured plugin for Worldwide Compliance.

Complianz contains GEO IP functionality to display the ‘correct’ type of Cookie Banner, either opt-in or opt-out, based on the region from which a visitor reaches your website.

If your site is behind a DDoS protection service such as CloudFlare, that service will be forwarding the traffic to your site. This means that the requests are received from that protection service, and the IP address would be stored in a different ‘header’.

Complianz’ GEO IP implementation will check the following header values (from top to bottom), and if the one being checked either does not exist or equals ‘127.0.0.1’, it moves on to the next one:

  • ‘HTTP_CF_CONNECTING_IP’,
  • ‘CF-IPCountry’,
  • ‘HTTP_TRUE_CLIENT_IP’,
  • ‘HTTP_X_CLUSTER_CLIENT_IP’,
  • ‘HTTP_CLIENT_IP’,
  • ‘HTTP_X_FORWARDED_FOR’,
  • ‘HTTP_X_FORWARDED’,
  • ‘HTTP_X_REAL_IP’,
  • ‘HTTP_FORWARDED_FOR’,
  • ‘HTTP_FORWARDED’,
  • ‘REMOTE_ADDR’

You can override the header that Complianz checks with the below filter, in case your set-up requires this:

Change HTTP_FORWARDED_FOR on line 3 to the header that Complianz should check for the IP address.

Recent articles

The Privacy Suite for WordPress
Get compliant today with the only Privacy Suite made for WordPress

Categories

Popular articles

Join our mailing list - 8 Tips & Tricks in your inbox over the next 8 weeks!