Proxy Your Browser RUM Data
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:
- 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
.
- Add a
X-Forwarded-For
header containing the request client IP address for accurate geoIP. - Forward the request to the Datadog intake URL using the POST method.
- Leave the request body unchanged.
The site parameter is an SDK initialization parameter. Datadog intake origins for each site are listed below:
Site | Site Parameter | Datadog intake origin |
---|
US1 | datadoghq.com (default) | https://browser-intake-datadoghq.com |
US3 | us3.datadoghq.com | https://browser-intake-us3-datadoghq.com |
US5 | us5.datadoghq.com | https://browser-intake-us5-datadoghq.com |
EU1 | datadoghq.eu | https://browser-intake-datadoghq.eu |
US1-FED | ddog-gov.com | https://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: