Skip to content
Nginx request_id module
Branch: master
Clone or download
Latest commit 770c99b Nov 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
t HH-63864 rename requestid Nov 1, 2016
README
config Fix bugs, add tests and new configuration method support Mar 22, 2016

README

The ngx_http_requestid_module is designed to generate a unique request identificator with timestamp.

Since nginx 1.11.0 has introduced the $request_id variable, this module is useful only for older versions of nginx or if you need a timestamp prepended request identifier.

The module sets $trequest_id variable with a unique request ID.

The $trequest_id variable is composed of (time){13} and (md5(ngx_pid, connection_number, rand())){19}, where:
  * time - timestamp in milliseconds
  * ngx_pid - nginx process id
  * connection_number - connection counter value local to worker process
  * rand() - random number

Supports both old and new configuration methods including dynamic compilation.

Example configurations:

# Set Proxy Header
location / {
     trequestid on;
     proxy_pass http://127.0.0.1;
     proxy_set_header X-Request-Id $trequest_id;
}


# Set HTTP Header
location / {
     add_header X-Request-Id $trequest_id;
}

# Write request id to log
log_format main '$remote_addr - $remote_user [$time_local]  '
		'"$request" $status $body_bytes_sent $trequest_id '
		'"$http_referer" "$http_user_agent"';


Configuration:

syntax: trequestid on | off
default: off
context: server, location

You can’t perform that action at this time.