---
title: "GeoIP on Acquia Cloud"
date: "2023-06-07T16:23:45+00:00"
summary:
image:
type: "article"
url: "/acquia-cloud-platform/help/88636-geoip-acquia-cloud"
id: "f492d48d-9604-4344-ae88-745084d317a5"
---

When developing a [Drupal](https://www.drupal.org/) application on [Acquia Cloud](https://www.acquia.com/products/drupal-cloud/cloud-platform) you may have the need to utilize the geographical location data and/or IP addresses of your visitors for application functionality. This article is for customers that don't have [Cloudflare](https://dev.acquia.com/blog/geoip-acquia-cloud-cloud-edge-powered-cloudflare) or [Akamai](https://dev.acquia.com/blog/geoip-acquia-cloud-cloud-edge-powered-akamai) and want to use [GeoIP functionality](/node/56174) in their Acquia-hosted Drupal application code.

To implement this feature, dedicated [load balancers](/node/56129) are required because the configuration involves Varnish customizations. Specifically, to add geographical functionality to Varnish, an additional Varnish Configuration Language file provides the country code of the user to the Drupal application. If your application doesn't currently utilize dedicated load balancers you can talk to your account manager to add them.

![Diagram illustrating Acquia Cloud architecture with servers, cloud, and user computers, showing data flow and integration points.](https://acquia.widen.net/content/1xnhgv6loi/web/url_28d038a2e69d2935cc905689d60b1690.svg?v=321e1675-89e7-4974-b85d-d6f29df8c588)

_Image: Diagram showing GeoIP on Acquia Cloud with Varnish._

Once you have the requisite architecture, customers can request to have Acquia enable IP-address-based country identification on their dedicated load balancer pair. This process adds an _addon-geoip.vcl_ file to the customer's Varnish layer.

Once this is enabled, backend applications will start receiving the HTTP request header _X-Geo-Country_ with a two-character ISO\_3166-1\_alpha-2 country identifier.

At this point the development team can add logic to the Drupal application to leverage the geographic data. This can be done multiple ways including in Drupal via PHP using the server variable:

    $_SERVER['HTTP_X_GEO_COUNTRY']

or within .htaccess as:

    %{HTTP:X-Geo-Country}

For more context on use cases, please see _[How to Use GeoIP Headers](https://acquia.my.site.com/s/article/360037811953-How-to-use-GeoIP-Headers)_.

If you need further help, please reach out to your account team and/or [Acquia Support](/node/55874).

**Notes:**

When there's no country, this is presumably because the data in the request header _X-Forwarded-For_ didn't match a valid IPv4 or IPv6 address. In these cases the header will be X-Geo-Country: AA.

Also reference: [Using GeoIP Information - Make country codes available with Maxmind](/node/56174)