Skip to content

hhru/nginx_requestid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published