Overview

The RUM Browser SDK can be configured to send requests through a proxy. Requests made still need to be forwarded to Datadog.

SDK initialization

When you set the proxy initialization parameter, all RUM data is sent to the specified URL using the POST method (for example, https://www.proxy.com/foo).

import { Datacenter, datadogRum } from '@datadog/browser-rum';

datadogRum.init({
    applicationId: '<DATADOG_APPLICATION_ID>',
    clientToken: '<DATADOG_CLIENT_TOKEN>',
    site: '<DATADOG_SITE>',
    proxy: '<YOUR_PROXY_URL>',
});
window.DD_RUM.onReady(function() {
    window.DD_RUM.init({
        clientToken: '<CLIENT_TOKEN>',
        applicationId: '<APPLICATION_ID>',
        proxy: '<YOUR_PROXY_URL>',
    })
})
window.DD_RUM &&
    window.DD_RUM.init({
        clientToken: '<CLIENT_TOKEN>',
        applicationId: '<APPLICATION_ID>',
        proxy: '<YOUR_PROXY_URL>'
    });

Proxy setup

When your proxy receives data from the RUM Browser SDK, it must be forwarded to Datadog. The RUM Browser SDK adds the ddforward query parameter to all POST requests to your proxy. This query parameter contains the URL path and parameters that all data must be forwarded to.

To successfully proxy request to Datadog:

  1. Build the final Datadog intake URL by using:
    • the Datadog intake origin corresponding to your site. See table below.
    • the path and parameters provided by ddforward.
  2. Add a X-Forwarded-For header containing the request client IP address for accurate geoIP.
  3. Forward the request to the Datadog intake URL using the POST method.
  4. Leave the request body unchanged.

The site parameter is an SDK initialization parameter. Datadog intake origins for each site are listed below:

SiteSite ParameterDatadog intake origin
US1datadoghq.com (default)https://browser-intake-datadoghq.com
US3us3.datadoghq.comhttps://browser-intake-us3-datadoghq.com
US5us5.datadoghq.comhttps://browser-intake-us5-datadoghq.com
EU1datadoghq.euhttps://browser-intake-datadoghq.eu
US1-FEDddog-gov.comhttps://browser-intake-ddog-gov.com

The Datadog intake origin corresponding to your site parameter should be defined in your proxy implementation.

Legacy proxy setups

Before Browser SDK v4.34.0, the proxyUrl initialization parameter was used and the Datadog intake origin was included in the ddforward attribute. The proxy implementation was in charge of validating this host and failure to do so resulted in various vulnerabilities.

The Datadog intake origin now needs to be defined in your proxy implementation to ensure security.

If you are still using a proxy with an older version of the Browser SDK, we recommend upgrading to a newer version of the Browser SDK.

Further Reading

Additional helpful documentation, links, and articles: