Merge pull request #3786 from Shopify/rewrite-x-forwarded-prefix

Fix x-forwarded-prefix annotation
This commit is contained in:
Kubernetes Prow Robot 2019-03-31 16:18:32 -07:00 committed by GitHub
commit b87cc5a1a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 121 additions and 22 deletions

View file

@ -503,8 +503,8 @@ func buildProxyPass(host string, b interface{}, loc interface{}) string {
if len(location.Rewrite.Target) > 0 {
var xForwardedPrefix string
if location.XForwardedPrefix {
xForwardedPrefix = fmt.Sprintf("proxy_set_header X-Forwarded-Prefix \"%s\";\n", path)
if len(location.XForwardedPrefix) > 0 {
xForwardedPrefix = fmt.Sprintf("proxy_set_header X-Forwarded-Prefix \"%s\";\n", location.XForwardedPrefix)
}
return fmt.Sprintf(`

View file

@ -48,7 +48,7 @@ var (
Location string
ProxyPass string
Sticky bool
XForwardedPrefix bool
XForwardedPrefix string
SecureBackend bool
enforceRegex bool
}{
@ -58,7 +58,7 @@ var (
"/",
"proxy_pass https://upstream_balancer;",
false,
false,
"",
true,
false,
},
@ -68,7 +68,7 @@ var (
"/",
"proxy_pass https://upstream_balancer;",
false,
false,
"",
true,
false,
},
@ -78,7 +78,7 @@ var (
"/",
"proxy_pass https://upstream_balancer;",
true,
false,
"",
true,
false,
},
@ -88,7 +88,7 @@ var (
"/",
"proxy_pass http://upstream_balancer;",
false,
false,
"",
false,
false,
},
@ -98,7 +98,7 @@ var (
"/",
"proxy_pass http://upstream_balancer;",
false,
false,
"",
false,
false,
},
@ -110,7 +110,7 @@ var (
rewrite "(?i)/" /jenkins break;
proxy_pass http://upstream_balancer;`,
false,
false,
"",
false,
true,
},
@ -122,7 +122,7 @@ proxy_pass http://upstream_balancer;`,
rewrite "(?i)/" /something break;
proxy_pass http://upstream_balancer;`,
true,
false,
"",
false,
true,
},
@ -134,7 +134,7 @@ proxy_pass http://upstream_balancer;`,
rewrite "(?i)/" /something break;
proxy_pass http://upstream_balancer;`,
true,
false,
"",
false,
true,
},
@ -147,7 +147,7 @@ rewrite "(?i)/there" /something break;
proxy_set_header X-Forwarded-Prefix "/there";
proxy_pass http://upstream_balancer;`,
true,
true,
"/there",
false,
true,
},
@ -157,7 +157,7 @@ proxy_pass http://upstream_balancer;`,
`~* "^/something"`,
"proxy_pass http://upstream_balancer;",
false,
false,
"",
false,
true,
},