NGINX Plus
NGINX Plus is a commercial version of the popular open-source web server and reverse proxy server software. NGINX provides performance, scalability, and reliability in serving web content and handling web traffic efficiently. NGINX Plus builds upon the features of the open-source NGINX with additional enterprise-grade features and support. Traceable supports NGINX R16 Plus and later.
Deployment steps
Deploying Traceable’s Tracing agent for NGINX Plus consists of the following steps:
Verify NGINX deployment type
Download the Tracing agent
Untar the downloaded file
Copy the
*.sofile to the modules directoryConfigure
nginx.conffileReload NGINX
Installation
Complete the following steps to deploy Traceable's NGINX tracing agent:
Step 1 - Verify NGINX deployment type
Enter the NGINX -V command to verify whether your NGINX is compiled with --compat flag. NGINX compiled with --compat flag allows loading dynamic modules.
If you do not see
--compatflag in the output, make sure that you have a NGINX version that is compiled with--compatflag.Take note of the value for
--modules-pathin the output. For example,/usr/lib/nginx/modulesand--modules-path=/usr/lib64/nginx/modules
Step 2 - Download
To download the NGINX agent, navigate to Traceable’s download site and click on agent > nginx > latest and search for your NGINX version. If you are running Alpine, download that version. Otherwise, select the one prefixed with Linux.
Step 3 - Untar the downloaded file
Enter the following command to untar the downloaded file:
After you untar the file, you would get the following two files:
ngx_http_traceableai_module.so- This is the dynamic module file.libtraceable.so- NGINX's blocking feature is dependent on this library file
Step 4 - Copy the *.so files
Enter the following command to copy the *.so files to the modules directory:
You can find the path to your modules directory by running the nginx -V command. For example, the path could be: --modules-path=/usr/lib64/nginx/modules.
Step 5 - Configure nginx.conf file
You can use vi editor or any editor of your choice to edit the nginx.conf file. The following command uses vi editor:
Add the load_module directive to the top of the file (after the user directive):
Add the traceableai directive inside the http block. Replace YOUR-SERVICE-NAME with the service name from your environment.
Content capture
You can configure the type of content you wish to capture. Configure capture_content_types inside the traceableai section. Capturing of the following content types is supported:
xmljsongrpcx-www-form-urlencoded
If you wish to capture xml json, specify the directive as capture_content_types xml json. If the directive is not specified, Traceable by default captures json, grpc, and x-www-form-urlencoded content as these are the most common content types.
opentracing and opentracing_propagate_context
Add the opentracing and opentracing_propagate_context after the traceableai block. For more information on opentracing_propagate_context, see Broken Correlation.
Optional - disable tracing
It is possible to disable tracing for individual location directives. Do so by defining opentracing off; inside the NGINX config file which contains the location to be excluded from tracing.
Optional - Add custom error code
You can add a custom error code in the 4xx series as a response status code when a request gets blocked. You can configure this in the nginx.conf file by setting blocking_status_code field in the traceableai section. The default value is set to 403. Following is an example snippet with the last line showing the blocking_status_code the value set to 472.
Following is a sample nginx.conf file:
Step 6 - Reload NGINX
Enter the following command to reload NGINX:
Definitions
traceableai syntax -
traceableai{}context -httpservice_name syntax -
service_name <identifiable_name_of_the_service>default -nginxcontext -traceableaiGive a meaningful name of service with which you can identify it on Traceable’s Dashboard.collector_host syntax -
collector_host <hostname_of_collector>default -collector.traceableaicontext -traceableaicollector_port syntax -
collector_port <port_of_collector>default -9411context -traceableaiblocking syntax -
opa on|offdefault -offcontext -traceableaiBy default OPA is disabled. OPA is required if you wish to enable blocking in NGINX deployment.opa_server syntax -
opa_server <opa_server_addressdefault -http://opa.traceableai:8181context -traceableaiURL on which OPA service is deployed for the NGINX module to communicate.opentracing syntax -
opentracing on|offdefault -offcontext -http, server, location` Enables or disables OpenTracing for NGINX requests.opentracing_propagate_context syntax -
opentracing_propagate_contextcontext -http, server, location` Opentracing_propagate_context propagates the active span context for upstream requests. For more information, see Inject and Extract.
Verification
You can complete the following steps to verify if the installation was successful:
Exercise the applications routing through NGINX.
Visit Traceable platform and confirm that traces are showing up.
Generate traffic (optional)
Traceable discovers APIs or displays metrics based on the user traffic. You need to proxy your application through NGINX. For example, if you have an application running on http://YourApplication.com:9191/order then add the following block to the /etc/nginx/conf.d/default.conf file.
After configuring the above, you can access your application from http://nginx-proxy.YourApplication.com/order. This assumes that NGINX proxy that is installed on nginx-proxy.YourApplication.com is configured to accept traffic on port number 80. You can also use HTTPS instead of HTTP.
Upgrade
To upgrade the NGINX tracing agent:
Install the module as per the install section.
Update the config in
nginx.confif needed.Restart nginx
Uninstall
Complete the following steps to uninstall NGINX tracing agent:
Remove the dynamic library files:
ngx_http_traceableai.module.soandlibtraceable.so.Remove the Traceable configuration lines from
nginx.confRestart NGINX
Troubleshooting
No Traces in Traceable
Tail the NGINX error logs:
Broken correlation
Identify all the location blocks in your NGINX configuration files. If they have the proxy_set_header directive defined, you will need to add opentracing_propagate_context to these location blocks. Check for any include statements that could potentially be including that directive. See the info message below.
Last updated
Was this helpful?