Merge pull request #2353 from bashofmann/master
Add proxy-add-original-uri-header config flag
This commit is contained in:
commit
564ec885fb
5 changed files with 31 additions and 17 deletions
|
@ -104,6 +104,7 @@ The following table shows a configuration option's name, type, and the default v
|
||||||
|[bind-address-ipv6](#bind-address-ipv6)|[]string|""|
|
|[bind-address-ipv6](#bind-address-ipv6)|[]string|""|
|
||||||
|[forwarded-for-header](#forwarded-for-header)|string|"X-Forwarded-For"|
|
|[forwarded-for-header](#forwarded-for-header)|string|"X-Forwarded-For"|
|
||||||
|[compute-full-forwarded-for](#compute-full-forwarded-for)|bool|"false"|
|
|[compute-full-forwarded-for](#compute-full-forwarded-for)|bool|"false"|
|
||||||
|
|[proxy-add-original-uri-header](#proxy-add-original-uri-header)|bool|"true"|
|
||||||
|[enable-opentracing](#enable-opentracing)|bool|"false"|
|
|[enable-opentracing](#enable-opentracing)|bool|"false"|
|
||||||
|[zipkin-collector-host](#zipkin-collector-host)|string|""|
|
|[zipkin-collector-host](#zipkin-collector-host)|string|""|
|
||||||
|[zipkin-collector-port](#zipkin-collector-port)|int|9411|
|
|[zipkin-collector-port](#zipkin-collector-port)|int|9411|
|
||||||
|
@ -585,6 +586,10 @@ Sets the header field for identifying the originating IP address of a client. De
|
||||||
|
|
||||||
Append the remote address to the X-Forwarded-For header instead of replacing it. When this option is enabled, the upstream application is responsible for extracting the client IP based on its own list of trusted proxies.
|
Append the remote address to the X-Forwarded-For header instead of replacing it. When this option is enabled, the upstream application is responsible for extracting the client IP based on its own list of trusted proxies.
|
||||||
|
|
||||||
|
## proxy-add-original-uri-header
|
||||||
|
|
||||||
|
Adds an X-Original-Uri header with the original request URI to the backend request
|
||||||
|
|
||||||
## enable-opentracing
|
## enable-opentracing
|
||||||
|
|
||||||
Enables the nginx Opentracing extension. By default this is disabled.
|
Enables the nginx Opentracing extension. By default this is disabled.
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -424,6 +424,10 @@ type Configuration struct {
|
||||||
// Default: false
|
// Default: false
|
||||||
ComputeFullForwardedFor bool `json:"compute-full-forwarded-for,omitempty"`
|
ComputeFullForwardedFor bool `json:"compute-full-forwarded-for,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"`
|
||||||
|
|
||||||
// EnableOpentracing enables the nginx Opentracing extension
|
// EnableOpentracing enables the nginx Opentracing extension
|
||||||
// https://github.com/rnburn/nginx-opentracing
|
// https://github.com/rnburn/nginx-opentracing
|
||||||
// By default this is disabled
|
// By default this is disabled
|
||||||
|
@ -536,6 +540,7 @@ func NewDefault() Configuration {
|
||||||
ErrorLogLevel: errorLevel,
|
ErrorLogLevel: errorLevel,
|
||||||
ForwardedForHeader: "X-Forwarded-For",
|
ForwardedForHeader: "X-Forwarded-For",
|
||||||
ComputeFullForwardedFor: false,
|
ComputeFullForwardedFor: false,
|
||||||
|
ProxyAddOriginalUriHeader: true,
|
||||||
HTTP2MaxFieldSize: "4k",
|
HTTP2MaxFieldSize: "4k",
|
||||||
HTTP2MaxHeaderSize: "16k",
|
HTTP2MaxHeaderSize: "16k",
|
||||||
HTTPRedirectCode: 308,
|
HTTPRedirectCode: 308,
|
||||||
|
|
|
@ -49,6 +49,7 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
||||||
"worker-shutdown-timeout": "99s",
|
"worker-shutdown-timeout": "99s",
|
||||||
"nginx-status-ipv4-whitelist": "127.0.0.1,10.0.0.0/24",
|
"nginx-status-ipv4-whitelist": "127.0.0.1,10.0.0.0/24",
|
||||||
"nginx-status-ipv6-whitelist": "::1,2001::/16",
|
"nginx-status-ipv6-whitelist": "::1,2001::/16",
|
||||||
|
"proxy-add-original-uri-header": "false",
|
||||||
}
|
}
|
||||||
def := config.NewDefault()
|
def := config.NewDefault()
|
||||||
def.CustomHTTPErrors = []int{300, 400}
|
def.CustomHTTPErrors = []int{300, 400}
|
||||||
|
@ -67,6 +68,7 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
||||||
def.WorkerShutdownTimeout = "99s"
|
def.WorkerShutdownTimeout = "99s"
|
||||||
def.NginxStatusIpv4Whitelist = []string{"127.0.0.1", "10.0.0.0/24"}
|
def.NginxStatusIpv4Whitelist = []string{"127.0.0.1", "10.0.0.0/24"}
|
||||||
def.NginxStatusIpv6Whitelist = []string{"::1", "2001::/16"}
|
def.NginxStatusIpv6Whitelist = []string{"::1", "2001::/16"}
|
||||||
|
def.ProxyAddOriginalUriHeader = false
|
||||||
|
|
||||||
to := ReadConfig(conf)
|
to := ReadConfig(conf)
|
||||||
if diff := pretty.Compare(to, def); diff != "" {
|
if diff := pretty.Compare(to, def); diff != "" {
|
||||||
|
|
|
@ -1009,7 +1009,9 @@ stream {
|
||||||
proxy_set_header X-Forwarded-Host $best_http_host;
|
proxy_set_header X-Forwarded-Host $best_http_host;
|
||||||
proxy_set_header X-Forwarded-Port $pass_port;
|
proxy_set_header X-Forwarded-Port $pass_port;
|
||||||
proxy_set_header X-Forwarded-Proto $pass_access_scheme;
|
proxy_set_header X-Forwarded-Proto $pass_access_scheme;
|
||||||
|
{{ if $all.Cfg.ProxyAddOriginalUriHeader }}
|
||||||
proxy_set_header X-Original-URI $request_uri;
|
proxy_set_header X-Original-URI $request_uri;
|
||||||
|
{{ end }}
|
||||||
proxy_set_header X-Scheme $pass_access_scheme;
|
proxy_set_header X-Scheme $pass_access_scheme;
|
||||||
|
|
||||||
# Pass the original X-Forwarded-For
|
# Pass the original X-Forwarded-For
|
||||||
|
|
Loading…
Reference in a new issue