GeoIP on Acquia Cloud with Cloud Edge

  • 3 minute read

When developing a Drupal application on Acquia Cloud you may have the need to utilize the IP addresses of your visitors for application functionality. If your team is using a reverse proxy CDN in front of the web stack this process can become slightly more complicated. A simple solution for this use case which I've implemented with multiple enterprise customers is outlined in this article. I'll keep it brief and to the point and comment on the changes that need to be implemented in order to make this work.

Image
Druplicon

In this use case we have Acquia Cloud Edge Powered by Cloudflare in front of a Drupal enterprise web application hosted on Acquia Cloud.

The diagram below illustrates two scenarios. The green numbers show the workflow of using GeoIP on Acquia Cloud without Cloudflare in the mix. The red numbers show the workflow of using GeoIP on Acquia Cloud with Cloudflare in the mix. It is important to note that dedicated load balancers are required with your subscription in both scenarios.

Image
GeoIP with Cloud Edge

Image: Diagram showing two scenarios for using GeoIP on Acquia Cloud.

In our scenario, when user traffic is proxied through Cloudflare, you will need to enable the True-Client-IP header which can be found in the Cloudflare administration dashboard under the Network tab. You will also need to enable the CF-IPCountry header which can also be found in the Cloudflare administration dashboard under the Network tab under IP Geolocation.

The final piece to the setup is a quick configuration change on the server stack at Acquia. You can talk to your TAM, CSM, or AM or file an Acquia Support ticket and request that Acquia enable CF-Connecting-IP on Acquia Cloud for your application. This can only be completed by Acquia Support engineers. Once this is in place you can use the header in PHP application code like:

$country_code = $_SERVER[HTTP_CF_IPCOUNTRY];

If you need further help, please reach out to your account team and/or Acquia Support.