diff --git a/CHANGELOG.md b/CHANGELOG.md index d05d196..5b38dec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/config/http.conf b/config/http.conf index 363af4e..1826b88 100644 --- a/config/http.conf +++ b/config/http.conf @@ -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; @@ -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; diff --git a/config/log.conf b/config/log.conf index a28ddca..047b6e4 100644 --- a/config/log.conf +++ b/config/log.conf @@ -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;