For the complete documentation index, see llms.txt. This page is also available as Markdown.

Reverse proxy

A reverse proxy is a method by which your organization can configure a custom domain to serve the Didomi SDKs and API assets through its own domain. When configured, a reverse proxy will route all traffic to your custom domain to your organization's inrastructure first before it is proxied Didomi. It will also allow your organization to do caching and traffic management.

Some benefits of implementing a custom domain via reverse proxy include:

  • Enhanced performance by leveraging Cloud and Edge providers' caching functionalities

  • Maintain brand consistency and reduce reliance on third-party domains.

  • Potentially improve compliance with privacy regulations by controlling SDK delivery.

In this article, we will cover the following in regards to your reverse proxy implementation


Main domain vs Subdomain Implementation

When implementing a reverse proxy for the Didomi SDK and its API events, your organization will need to decide between using its main domain or a dedicated subdomain.

Implementation

Main domain

Serves the SDK through as a subpath on your primary domain (e.g., domain.com/consent/* or www.domain.com/consent/*) that users access your website on.

Dedicated subdomain

Serves the SDK through a separate subdomain (e.g., sub.domain.com) directed to the Didomi CMP.

Guidelines

In this section, we provide guidelines for how your organization can implement reverse proxy for either your organization's main domain or a dedicated subdomain.

Please see our implementation guides to see if we provide dedicated resources for your organization's specific platform.

Proxy Didomi endpoints

Regardless of whether your organization configures a reverse proxy for its main domain or a dedicated subdomain, you will want to proxy the relevant endpoints for:

The Didomi SDKs are served on sdk.privacy-center.org and is composed of the following files:

Name
Update frequency
Cache lifetime
Description

Loader

Every time a new version of the consent notice is published or when Didomi releases a new version of the Web SDK (up to a few times a week).

Short (from minutes up to 1 hour)

Dynamic file that contains the configuration of consent notices. The file is specific to every organization and notice. Pattern: https://sdk.privacy-center.org/{Public API Key}/loader.js

Core

When Didomi releases a new version of the Web SDK (up to a few times a week).

Long (1 year)

Static JavaScript file that contains the logic of the SDK. Pattern: https://sdk.privacy-center.org/sdk/{Version ID}/.sdk.{Version ID}.{Browser support}.js

UI

When Didomi releases a new version of the Web SDK (up to a few times a week).

Long (1 year)

Static JavaScript files that contain all the UI of the SDK.:

Patterns:

  • https://sdk.privacy-center.org/sdk/{Version ID}/ui-{Regulation}-{Language}-web.{Version ID}.{Browser support}.js (for GDPR and other regulations with multiple languages)

  • https://sdk.privacy-center.org/sdk/{Version ID}/ui-ccpa.{Version ID}.{Browser support}.js

  • https://sdk.privacy-center.org/sdk/{Version ID}/ui-cpa.{Version ID}.{Browser support}.js

  • https://sdk.privacy-center.org/sdk/{Version ID}/ui-cpra.{Version ID}.{Browser support}.js

  • https://sdk.privacy-center.org/sdk/{Version ID}/ui-ctdpa.{Version ID}.{Browser support}.js

  • https://sdk.privacy-center.org/sdk/{Version ID}/ui-vcdpa.{Version ID}.{Browser support}.js

  • https://sdk.privacy-center.org/sdk/{Version ID}/iab-texts.{Version ID}.{Browser support}.js (IAB vendor information)

The Didomi API is available on api.privacy-center.org. All requests sent to the API must be proxied to the domain without any caching.

Implementation

Select the tabs below below to learn more about implementing reverse proxy on your organization's main domain or dedicated subdomain

In this tab, we will cover the implementation steps needed specific to configuring a reverse proxy for your organization's main domain.

Configure reverse proxy

We will use client.com/consent/ as an example in this article.

1

The proxy must query the Didomi URL in HTTPS for all files from https://client.com/consent/ to https://sdk.privacy-center.org with their associated path, method, headers, and body.

For instance, the request GET https://client.com/consent/loader.js?domain=... should be proxied to GET https://sdk.privacy-center.org/loader.js?domain=...

2

The proxy must query the Didomi URL in HTTPS for all requests to https://client.com/consent/api/ to https://api.privacy-center.org with their associated path, method, headers, and body.

For instance, the request POST https://client.com/consent/api/events should be proxied to POST https://api.privacy-center.org/events.

Add end-user country and region

In addition to the above rules, your organization will need to add the ISO 3166-1 alpha-2 country and ISO 3166-2 region code to your notice configuration on page load to ensure that the correct loader.js file is downloaded from our services to be cached by your proxy correctly.

Add the user country and region directly to your local SDK config object during page load, dynamically setting the window.didomiConfig.user.country and window.didomiConfig.user.region properties to have their values equal to a valid country and region codes. These settings will override the default geolocation behavior on the loader.js route.

In the example above, an end-user located in California, USA who loads the SDK will end up making a request to the Didomi CDN with country=US and region=CA parameters at load time.

Example

The request will be proxied to: https://sdk.privacy-center.org/{public API key}/loader.js?target_type=notice&target=4QS9p3Qn&country=US&region=CA

Click here for more information on leveraging the didomiConfig object for controlling the behavior of an end-user's location. Please note that this may require obtaining a new embed code for your notice and updating the embed code in your HTML if your consent notice was created earlier than September 2023.

In this tab, we will cover the implementation steps needed specific to configuring a reverse proxy for a dedicated subdomain.

Create dedicated subdomain

Create a dedicated sub-domain and point it to your reverse proxy.

We will use dsdk.client.com as an example in this article but any subdomain that your organization creates will work.

Configure reverse proxy

Using the reverse proxy software of your choice, apply the following rules:

1

The proxy must query the Didomi URL in HTTPS for all files from https://dsdk.client.com to https://sdk.privacy-center.org with their associated path, method, headers, and body.

For instance, the request GET https://dsdk.client.com/loader.js?domain=... should be proxied to GET https://sdk.privacy-center.org/loader.js?domain=...

2

The proxy must query the Didomi URL in HTTPS for all requests to https://dsdk.client.com/api/ to https://api.privacy-center.org with their associated path, method, headers, and body.

For instance, the request POST https://dsdk.client.com/api/events should be proxied to POST https://api.privacy-center.org/events.

Add end-user country and region

In addition to the above rules, your organization will need to add the ISO 3166-1 alpha-2 country and ISO 3166-2 region code to your notice configuration on page load to ensure that the correct loader.js file is downloaded from our services to be cached by your proxy correctly.

Add the user country and region directly to your local SDK config object during page load, dynamically setting the window.didomiConfig.user.country and window.didomiConfig.user.region properties to have their values equal to a valid country and region codes. These settings will override the default geolocation behavior on the loader.js route.

In the example above, an end-user located in California, USA who loads the SDK will end up making a request to the Didomi CDN with country=US and region=CA parameters at load time.

Example

The request will be proxied to: https://sdk.privacy-center.org/{public API key}/loader.js?target_type=notice&target=4QS9p3Qn&country=US&region=CA

Click here for more information on leveraging the didomiConfig object for controlling the behavior of an end-user's location. Please note that this may require obtaining a new embed code for your notice and updating the embed code in your HTML if your consent notice was created earlier than September 2023.

Regardless of whether your organization configures a reverse proxy for its main domain or a dedicated subdomain, the following implementation steps must also be configured:

Requests to origin (Didomi CDN)

When proxying a request to the Didomi CDN, your proxy should be configured with the following rules:

Rule
Description

Forward and cache based on path and query string

The full path and query string of requests sent to sdk.privacy-center.org must be forwarded in its entirety to the Didomi CDN. Caching must be done on the full path and query string. Requests to api.privacy-center.org must never be cached.

Cache based on geo (ISO country and region)

The Didomi CDN files are generated and served based on the end-user's ISO country and region codes (determined from the end-user's IP). Ensure that your proxy acts the same way and caches different versions of a given file based on the country and region of the user request.

Files returned by the Didomi CDN are not specific to a given end-user but to the end-user's country and region.

Requests to api.privacy-center.org must never be cached.

Do not forward cookies

Cookies should not be forwarded to the Didomi CDN and can be discarded from the request.

Forward end-user IP

The original IP of the end-user should be forwarded to the Didomi CDN in the X-Forwarded-For header.

Caching

The proxy your organization configures must cache files based on:

  • The full path and query string

  • The end-user country and region ISO codes

If the reverse proxy does not correctly cache files based on the rules listed above it can be the case that the wrong consent notice could be returned and shown to the end-user (e.g., a GDPR consent notice could be shown to a California end-user even if you have configured CPRA for your consent notice).

Responses from origin (Didomi CDN) and caching headers

After receiving a file from the Didomi CDN, your proxy must respect all cache headers returned by the Didomi CDN (Cache-Control, Expires, etc.) to ensure that files updated on the Didomi CDN get updated in your proxy as well.

Your organization must return the cache headers to the end-user as well to limit the number of requests sent by end-users to your proxy and the number of requests sent by your proxy to the Didomi CDN.

If your proxy is querying the Didomi CDN more often than indicated by the cache headers, it must include HTTP headers like If-Modified-Since or Etag from the cached files.

Files can be cached locally by your proxy and returned if stale to increase reliability.

Limits

The following limits apply when using a reverse proxy to serve the Didomi SDK. When your organization publishes changes to a consent notice with the default SDK domain, the consent notice is instantaneously updated on your website. The cache of the Didomi CDN is invalidated to ensure that the changes are immediate. With a reverse proxy, an additional delay is added as the cache of the proxy is not immediately cleared. Having a mechanism to clear the proxy cache after publishing a consent notice can help resolve this problem.

Implementation guides

For your organization's convenience, Didomi has compiled dedicated resources for implementing reverse proxy for the following platforms:

Last updated