Skip to content

Commit

Permalink
Merge pull request #5 from Intellection/add_support_for_request_tracing
Browse files Browse the repository at this point in the history
Add support for request tracing via X-Request-ID header
  • Loading branch information
itskingori authored Feb 10, 2021
2 parents bc694d3 + 859dc65 commit caa3c62
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.19.5-3

* Set or forward `X-Request-ID`.
* Add computed `X-Request-ID` to the access logs.

## 1.19.5-2

* Forward `X-Forwarded-*` headers to upstream correctly.
Expand Down
8 changes: 8 additions & 0 deletions config/http.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ http {
'' $server_port;
}

# If we receive X-Request-ID, pass it through; otherwise, pass along the
# request_id generated by nginx
map $http_x_request_id $proxy_x_request_id {
default $http_x_request_id;
'' $request_id;
}

proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
Expand All @@ -39,6 +46,7 @@ http {
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
proxy_set_header X-Request-ID $proxy_x_request_id;
proxy_set_header X-Forwarded-Host $host;

proxy_read_timeout 600s;
Expand Down
2 changes: 1 addition & 1 deletion config/log.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
'"$http_user_agent" "$http_x_forwarded_for" $proxy_x_request_id';

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

0 comments on commit caa3c62

Please sign in to comment.