Skip to content

Commit caa3c62

Browse files
authored
Merge pull request #5 from Intellection/add_support_for_request_tracing
Add support for request tracing via X-Request-ID header
2 parents bc694d3 + 859dc65 commit caa3c62

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 1.19.5-3
4+
5+
* Set or forward `X-Request-ID`.
6+
* Add computed `X-Request-ID` to the access logs.
7+
38
## 1.19.5-2
49

510
* Forward `X-Forwarded-*` headers to upstream correctly.

config/http.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ http {
3030
'' $server_port;
3131
}
3232

33+
# If we receive X-Request-ID, pass it through; otherwise, pass along the
34+
# request_id generated by nginx
35+
map $http_x_request_id $proxy_x_request_id {
36+
default $http_x_request_id;
37+
'' $request_id;
38+
}
39+
3340
proxy_http_version 1.1;
3441
proxy_set_header Connection "";
3542
proxy_set_header Host $host;
@@ -39,6 +46,7 @@ http {
3946
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
4047
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
4148
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
49+
proxy_set_header X-Request-ID $proxy_x_request_id;
4250
proxy_set_header X-Forwarded-Host $host;
4351

4452
proxy_read_timeout 600s;

config/log.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
log_format main '$remote_addr - $remote_user [$time_local] $status '
22
'"$request" $body_bytes_sent "$http_referer" '
3-
'"$http_user_agent" "$http_x_forwarded_for"';
3+
'"$http_user_agent" "$http_x_forwarded_for" $proxy_x_request_id';
44

55
access_log /dev/stdout main;
66
error_log /dev/stdout warn;

0 commit comments

Comments
 (0)