HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Configure CDN

Describes how to configure header settings with regards to personalization in a Content Delivery Network (CDN) environment for Optimizely Content Management System (CMS).

Configure Optimizely Content Management System (CMS) to read the client IP and country from Content Delivery Network (CDN) headers so personalization rules target the actual visitor, not the CDN edge server.

In CDNs, requests to the web server often come from an edge server, not from the actual client. The HttpContext.Request.UserHostAddress property reflects the edge server's IP address rather than the connecting client's.

When personalizing content based on the client's IP address (for example, geolocation), base the content on the client's IP address, not the edge server's.

Set the client IP header

CDNs forward the connecting client information in HTTP headers. To personalize content based on the IP address in a CDN, configure the header with the true client IP. Header names differ between CDNs, so set the header name to match the header sent from your CDN:

{
  "EPiServer": {
    "Cms": {
      "ClientGeolocation": {
        "IPAddressHeader": "True-Client-IP"
      }
    }
  }
}

Use X-Forwarded-For header

Most CDNs support the X-Forwarded-For header, which contains a comma-separated list of IP addresses: one for each CDN or proxy a request passes through. Use the same settings to enable it.

{
  "EPiServer":{
    "Cms":{
      "ClientGeolocation":{
         "IPAddressHeader":"X-Forwarded-For"
      }
    }
  }
}

Specify the number of CDNs or proxies the header contains. The default value is 1. Change this value when your deployment uses more than one CDN or proxy.

{
  "EPiServer":{
    "Cms":{
      "ClientGeolocation":{
         "IPAddressHeaderProxyCount":"2"
      }
    }
  }
}
📘

Note

Specifying the number of CDNs or proxies protects against IP spoofing. The setting episerver:ClientIPAddressProxyCount is available as of CMS.Core 9.3.2. In previous versions, you cannot change the default value of 1.

Retrieve geographic location

Some CDN providers, such as Cloudflare, identify a visitor's geographic location and add the country code to one of the headers passed to the web server. As of CMS version 11.9.0, you can base geographic personalization on this header instead of running a separate IP lookup through a geolocation provider. To enable this feature, specify which header to use for the country code.

{
  "EPiServer":{
    "Cms":{
      "ClientGeolocation":{
         "LocationHeader":"CF-IPCountry"
      }
    }
  }
}
📘

Note

Header-based geolocation applies only when no geolocation provider is configured and is limited to country and continent locations. Optimizely Digital Experience Platform (DXP) customers have this feature enabled by default.