NGINX OpenTelemetry Web Tracing Guide
Instrument NGINX with OpenTelemetry for request-flow, latency, and error visibility.
NGINX is a critical application entry point and traffic handler, efficiently managing high-concurrency, low-latency traffic. Instrumenting NGINX with OpenTelemetry gives HEAL visibility into request flow, latency, error rates, and upstream service interactions, enabling proactive troubleshooting and performance optimization.
This guide describes the prerequisites, configuration steps, and validation procedures required to deploy OpenTelemetry web tracing for NGINX with HEAL. Using Apache, IBM HTTP Server (IHS), or Oracle HTTP Server? See the Web Tracing guide instead. This guide covers the otel_ngx_module.so bundle, whose directives all begin with opentelemetry_. If your bundle instead contains ngx_otel_module.so, uses otel_ directives and ships with an install script, see the NGINX OpenTelemetry Tracing Deployment Guide (ngx_otel_module) — the two directive sets are not interchangeable.
Prerequisites#
- NGINX is installed on the target system.
- An OpenTelemetry Collector is reachable from the NGINX host.
- You have the required privileges to modify NGINX configuration files.
- A backup of the existing NGINX configuration is available.
Note: Before making any changes, validate the existing NGINX configuration and take a backup of the current nginx.conf.
Installation Procedure#
Follow the steps below to install the OpenTelemetry NGINX module:
-
Extract the OpenTelemetry bundle. Navigate to the installation directory:
cd /HealExtract the OpenTelemetry NGINX bundle for your host architecture:
# x86_64 hosts tar -xzf nginx-otel-bundle-x86_64-rhel8.tar.gz # s390x hosts tar -xzf nginx-otel-bundle-s390x-rhel8.tar.gzNote: The bundle name is platform-specific — use the x86_64 or s390x variant that matches your host architecture. Both bundles are delivered with the HEAL release package (contact HEAL Support if you do not have the one you need).
Extraction creates the following directory, which acts as the root directory of the OpenTelemetry-enabled NGINX bundle:
/<path-to>/nginx-otel-bundle -
Set runtime environment variables. Configure the required environment variables so that NGINX can locate the OpenTelemetry binaries and shared libraries at runtime.
Base installation directory, where the OpenTelemetry NGINX bundle is present:
export NGINX_OTEL_HOME=/<path-to>/nginx-otel-bundleEnsure the required shared libraries are available at runtime:
export LD_LIBRARY_PATH=$NGINX_OTEL_HOME/libAdd the bundled NGINX binaries and tools to the system path:
export PATH=$NGINX_OTEL_HOME/bin:$PATH -
Load the OpenTelemetry module. Edit the existing NGINX configuration file at
/etc/nginx/nginx.confand load the OpenTelemetry dynamic module by adding the following line at the very top of the file:load_module $NGINX_OTEL_HOME/modules/otel_ngx_module.so;Note: This directive must be added before any
events {}orhttp {}blocks.
Configure OpenTelemetry#
Within the http {} block, configure the OpenTelemetry tracing and service parameters as follows:
-
Set the OpenTelemetry Collector endpoint that receives trace data:
opentelemetry_otlp_traces_endpoint http://<COLLECTOR_IP>:4318/v1/traces; -
Set the logical service name displayed in tracing backends (Jaeger, Tempo, HEAL APM):
opentelemetry_service_name nginx-otel-client; -
Add a sample server configuration to validate tracing:
server { listen 80; # Listens for HTTP traffic on port 80 location / { opentelemetry_propagate; # Propagates trace context headers (traceparent, baggage) opentelemetry_operation_name "client_test_request"; # Span/operation name shown in the tracing backend return 200 "NGINX OTel Client Test OK\n"; # Simple response to confirm tracing works } }
Validate NGINX Configuration#
Verify the NGINX configuration before restarting the service:
nginx -t
Expected output:
syntax is ok
test is successful
The output confirms the following:
- The OpenTelemetry module is loaded successfully.
- No syntax errors exist in
nginx.conf.
Restart NGINX#
Restart NGINX to apply the configuration changes:
-
Validate the updated configuration once more if you have made further edits:
nginx -t -
Restart NGINX using the updated configuration:
systemctl restart nginxAlternatively, if NGINX is already running and you only need to apply configuration changes, reload it in place:
nginx -s reload
Generate Test Traffic#
From the same host or a remote client, send an HTTP request to NGINX:
curl http://<nginx-host>/
Expected output:
NGINX OTel Client Test OK
The output confirms the following:
- NGINX is reachable.
- The test endpoint is functioning as expected.
Verify Traces in the Observability Backend#
Access the configured OpenTelemetry backend (Jaeger, Tempo, or HEAL APM) and confirm the following:
- Service name:
nginx-otel-client, as defined inopentelemetry_service_name. - Operation name:
client_test_request, as defined inopentelemetry_operation_name. - Behaviour: a new trace/span is generated for each HTTP request, with proper parent-child relationships when propagation is enabled.
Successful completion of the above steps confirms that end-to-end OpenTelemetry tracing is enabled and operational for NGINX.
Next
- Web Tracing — instrument Apache, IHS, and OHS web servers with the OpenTelemetry web server module.
- Transaction Monitoring — see how traced requests surface as transactions in HEAL.