Implement generate-request-id
Fixes https://github.com/kubernetes/ingress-nginx/issues/2546
This commit is contained in:
parent
d61eb2da7c
commit
206d32a2cd
3 changed files with 12 additions and 0 deletions
|
@ -105,6 +105,7 @@ The following table shows a configuration option's name, type, and the default v
|
|||
|[forwarded-for-header](#forwarded-for-header)|string|"X-Forwarded-For"|
|
||||
|[compute-full-forwarded-for](#compute-full-forwarded-for)|bool|"false"|
|
||||
|[proxy-add-original-uri-header](#proxy-add-original-uri-header)|bool|"true"|
|
||||
|[generate-request-id](#generate-request-id)|bool|"true"|
|
||||
|[enable-opentracing](#enable-opentracing)|bool|"false"|
|
||||
|[zipkin-collector-host](#zipkin-collector-host)|string|""|
|
||||
|[zipkin-collector-port](#zipkin-collector-port)|int|9411|
|
||||
|
@ -601,6 +602,10 @@ Append the remote address to the X-Forwarded-For header instead of replacing it.
|
|||
|
||||
Adds an X-Original-Uri header with the original request URI to the backend request
|
||||
|
||||
## generate-request-id
|
||||
|
||||
Ensures that X-Request-ID is defaulted to a random value, if no X-Request-ID is present in the request
|
||||
|
||||
## enable-opentracing
|
||||
|
||||
Enables the nginx Opentracing extension. _**default:**_ is disabled
|
||||
|
|
|
@ -429,6 +429,10 @@ type Configuration struct {
|
|||
// Default: false
|
||||
ComputeFullForwardedFor bool `json:"compute-full-forwarded-for,omitempty"`
|
||||
|
||||
// If the request does not have a request-id, should we generate a random value?
|
||||
// Default: true
|
||||
GenerateRequestId bool `json:"generate-request-id,omitempty"`
|
||||
|
||||
// Adds an X-Original-Uri header with the original request URI to the backend request
|
||||
// Default: true
|
||||
ProxyAddOriginalUriHeader bool `json:"proxy-add-original-uri-header"`
|
||||
|
@ -546,6 +550,7 @@ func NewDefault() Configuration {
|
|||
ForwardedForHeader: "X-Forwarded-For",
|
||||
ComputeFullForwardedFor: false,
|
||||
ProxyAddOriginalUriHeader: true,
|
||||
GenerateRequestId: true,
|
||||
HTTP2MaxFieldSize: "4k",
|
||||
HTTP2MaxHeaderSize: "16k",
|
||||
HTTPRedirectCode: 308,
|
||||
|
|
|
@ -277,7 +277,9 @@ http {
|
|||
# If no such header is provided, it can provide a random value.
|
||||
map $http_x_request_id $req_id {
|
||||
default $http_x_request_id;
|
||||
{{ if $cfg.GenerateRequestId }}
|
||||
"" $request_id;
|
||||
{{ end }}
|
||||
}
|
||||
|
||||
{{ if $cfg.ComputeFullForwardedFor }}
|
||||
|
|
Loading…
Reference in a new issue