---
title: Instrumenting Apache Server
description: >-
  Configure Apache httpd server to automatically inject RUM Browser SDK into
  HTML responses using the Datadog module.
breadcrumbs: >-
  Docs > RUM & Session Replay > Application Monitoring > RUM Browser Monitoring
  > Browser Monitoring Setup > Auto-Instrumentation > Instrumenting Apache
  Server
---

# Instrumenting Apache Server

{% callout %}
# Important note for users on the following Datadog sites: app.ddog-gov.com



{% alert level="danger" %}
RUM Auto-Instrumentation is not available for the selected site (). Use [Client-Side instrumentation](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser/setup/client) instead.
{% /alert %}


{% /callout %}

{% callout %}
##### Preview

RUM Auto-Instrumentation for Apache is in Preview.
{% /callout %}

## Overview{% #overview %}

RUM Auto-Instrumentation works by injecting the RUM Browser SDK into the HTML responses being served through a web server or proxy. This method leverages the [Apache httpd Modules capability](https://httpd.apache.org/modules/) to implement a response body filter. The filter injects the RUM Browser SDK into the response body for responses identified as HTML. After auto-instrumentation is set up, you can manage configurations from the UI.

## Limitations{% #limitations %}

Auto-instrumentation for this server has the following limitations. If your use case requires more control, use [client-side instrumentation](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser/setup/client) instead.

- This instrumentation method **does not support [advanced RUM configurations](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser/advanced_configuration/)**.
- If your web server is acting as a proxy and the upstream server uses **end-to-end encryption** (TLS) or **content compression** (gzip, zstd, Brotli), the RUM Browser SDK **cannot be injected**. For proper instrumentation:
  - **Disable content compression** on the upstream server.
  - **Enable TLS origination** on the web server.

## Prerequisites{% #prerequisites %}

The [Datadog Agent](https://docs.datadoghq.com/agent/) is installed and configured.

## Set up your RUM application{% #set-up-your-rum-application %}

To automatically instrument your RUM application:

1. In Datadog, navigate to the **Digital Experience > Manage Applications Page**, click on [**New Application**](https://app.datadoghq.com/rum/list), and select the JavaScript (JS) application type.
1. Select **Auto-Instrumentation** and **Apache httpd**.
1. Configure your application parameters. See [guidance on configuring sampling](https://docs.datadoghq.com/real_user_monitoring/guide/sampling-browser-plans/).
1. Copy and run the installer command to load the Datadog httpd Module with the RUM SDK Injector onto httpd.
1. After the installer successfully installs the SDK Injector, restart Apache HTTP Server to begin collecting RUM sessions.
1. (Optional) To verify the module is successfully injecting the RUM Browser SDK into HTML pages, check the error logs for relevant messages. The module logs important steps during the injection process. Ensure that Apache HTTP Server is configured with at least the `info` log level.

Alternatively, you can manually install and configure the module.

## Updating your RUM application{% #updating-your-rum-application %}

You can update your RUM application settings at any time. From the [Application Management](https://app.datadoghq.com/rum/list) list, select your RUM application and navigate to the **SDK Configuration** page. Click **Save Changes** after making updates.

### Sampling rates{% #sampling-rates %}

Adjust the slider or enter a specific percentage in the input box for Session Sampling or Session Replay Sampling. Copy and paste the configuration snippet to your `/opt/datadog-httpd/datadog.conf` file.

## Advanced configuration{% #advanced-configuration %}

After you have RUM Auto-Instrumentation set up, configure **User Attributes** and **Allowed Tracing URLs** directly from the Datadog UI without modifying your application code.

### User attributes{% #user-attributes %}

User Attributes allow you to associate RUM sessions with specific users, enabling you to:

- Track individual user journeys across your application
- Filter and search sessions by user details
- Gain insights into user-specific issues and behaviors

Configure three user properties: **User ID**, **User Name**, and **User Email**.

#### Source types{% #source-types %}

For each user attribute, select how the RUM SDK should extract the value:

| Source         | Description                                           | Example                                           |
| -------------- | ----------------------------------------------------- | ------------------------------------------------- |
| **JavaScript** | Read from a JavaScript variable on the page           | `window.currentUser.id` or `dataLayer.user.email` |
| **Cookie**     | Read from a browser cookie                            | Cookie name: `user_session`                       |
| **DOM**        | Read from an HTML element's text content or attribute | CSS selector: `#user-id` or `[data-user-email]`   |

#### Regex extractor (optional){% #regex-extractor-optional %}

Use a regex pattern to extract specific values when your source contains extra characters. For example:

- Source value: `user_id=12345;session=abc`
- Regex pattern: `user_id=(\d+)`
- Extracted value: `12345`

If your regex pattern includes a capture group (parentheses), the SDK extracts that value. Otherwise, it extracts the entire matched string.

### Allowed tracing URLs{% #allowed-tracing-urls %}

Configure allowed tracing URLs to connect your RUM sessions to backend APM traces. This provides end-to-end visibility from the browser to your backend services.

When a user's browser makes a request to an allowed URL, the RUM SDK injects trace headers. Your backend APM agent reads these headers and links the backend trace to the RUM session.

#### Configuration{% #configuration %}

Add the URLs of your backend services that you want to connect to RUM:

| Field               | Description                                                                                                                                                             |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **URL**             | The backend URL to trace. Use an exact URL (for example, `https://api.example.com`) or enable **Regex** for pattern matching (for example, `https://.*\.example\.com`). |
| **Propagator Type** | The trace header format your backend expects. Options: `datadog`, `tracecontext` (W3C), `b3`, `b3multi`. Select multiple if needed.                                     |

{% alert level="info" %}
Tracing requires a configured **service name**. Set this in the App Attributes section.
{% /alert %}

#### Learn more{% #learn-more %}

See [Connect RUM and Traces](https://docs.datadoghq.com/real_user_monitoring/platform/connect_rum_and_traces/) for detailed information about RUM and APM integration.

## Troubleshooting{% #troubleshooting %}

### RUM is not injected{% #rum-is-not-injected %}

If you notice that RUM is not being injected into HTML pages, consider the following potential causes:

- **Content-Type mismatch**: RUM is injected only into HTML pages. If the `Content-Type` header does not correctly indicate `text/html`, the injection is skipped.

## Uninstall{% #uninstall %}

To manually remove RUM from your auto-instrumented web server:

1. Locate the Apache (`httpd`) configuration file by running `httpd -V`. Depending on the Linux distribution used, this binary file could be named `http`, `apachectl`, `apache2` or `apache2ctl`. The following steps use `httpd` as an example. In this instance, the file location could be: `/usr/local/apache2/conf/httpd.conf`.
1. At the end of the httpd configuration file, remove the line: `Include /opt/datadog-httpd/datadog.conf`.
1. Delete the directory `/opt/datadog-httpd/` and all of its contents.
1. Restart or reload Apache httpd.

## Alternative installation method{% #alternative-installation-method %}

If you need finer control over more parameters than what the automatic instrumentation provides, you can manually load the module onto your web server instead of running the installation script.

To manually instrument your RUM application:

### Download the module file{% #download-the-module-file %}

1. Download the [zipped module](https://rum-auto-instrumentation.s3.amazonaws.com/httpd/latest/mod_datadog-amd64.zip).
1. Extract the zip to obtain the `mod_datadog.so` file. Move it to a location that Apache HTTP Server has access to (referenced as `<RUM_MODULE_PATH>` in the steps below).

### Update Apache HTTP server configuration{% #update-apache-http-server-configuration %}

1. Locate the configuration file. You can use `apachectl -V` to find the default configuration path. Add the following line to load the module:

   ```javascript
   LoadModule datadog_module <RUM_MODULE_PATH>
   ```

1. Within the appropriate **root** or **location** section, add the following:

   ```javascript
   # APM Tracing is enabled by default. The following line disables APM Tracing
   DatadogTracing Off
   DatadogRum On
   <DatadogRumSettings "v6">
       DatadogRumOption "applicationId" "<DATADOG_APPLICATION_ID>"
       DatadogRumOption "clientToken" "<DATADOG_CLIENT_TOKEN>"
       DatadogRumOption "site" "<DATADOG_SITE>"
       DatadogRumOption "service" "my-web-application"
       DatadogRumOption "env" "production"
       DatadogRumOption "version" "1.0.0"
       DatadogRumOption "sessionSampleRate" "100"
       DatadogRumOption "sessionReplaySampleRate" "100"
       DatadogRumOption "trackResources" "true"
       DatadogRumOption "trackLongTasks" "true"
       DatadogRumOption "trackUserInteractions" "true"
   </DatadogRumSettings>
   ```

### Restart your server{% #restart-your-server %}

1. Restart the Apache HTTP Server to begin collecting data for your Datadog RUM application. By default, the RUM SDK is injected to all HTML documents. You may need to clear your browser cache.
1. (Optional) To verify the module is successfully injecting the RUM Browser SDK into HTML pages, check the httpd error logs for relevant messages. The module logs important steps during the injection process. Ensure that Apache HTTP Server is configured with at least the `info` log level.

## Further reading{% #further-reading %}

- [Browser Monitoring Auto-Instrumentation](https://docs.datadoghq.com/real_user_monitoring/application_monitoring/browser/setup/server)
