diff --git a/ingress/controllers/nginx/Changelog.md b/ingress/controllers/nginx/Changelog.md index f985d24192..0620d1179c 100644 --- a/ingress/controllers/nginx/Changelog.md +++ b/ingress/controllers/nginx/Changelog.md @@ -4,6 +4,7 @@ Changelog - [X] [#1063](https://github.com/kubernetes/contrib/pull/1063) watches referenced tls secrets - [X] [#850](https://github.com/kubernetes/contrib/pull/850) adds configurable SSL redirect nginx controller +- [ ] [#1136](https://github.com/kubernetes/contrib/pull/1136) Fix nginx rewrite rule order ### 0.7 diff --git a/ingress/controllers/nginx/nginx/template.go b/ingress/controllers/nginx/nginx/template.go index d28cd9e651..b12641efaf 100644 --- a/ingress/controllers/nginx/nginx/template.go +++ b/ingress/controllers/nginx/nginx/template.go @@ -173,10 +173,10 @@ func buildProxyPass(input interface{}) string { // special case redirect to / // ie /something to / return fmt.Sprintf(` - rewrite %s / break; rewrite %s(.*) /$1 break; + rewrite %s / break; proxy_pass %s://%s; - %v`, location.Path, path, proto, location.Upstream.Name, abu) + %v`, path, location.Path, proto, location.Upstream.Name, abu) } return fmt.Sprintf(` diff --git a/ingress/controllers/nginx/nginx/template_test.go b/ingress/controllers/nginx/nginx/template_test.go index 006f0dda5e..f13aaf339a 100644 --- a/ingress/controllers/nginx/nginx/template_test.go +++ b/ingress/controllers/nginx/nginx/template_test.go @@ -38,8 +38,8 @@ var ( proxy_pass http://upstream-name; `, false}, "redirect /something to /": {"/something", "/", "~* /something", ` - rewrite /something / break; rewrite /something/(.*) /$1 break; + rewrite /something / break; proxy_pass http://upstream-name; `, false}, "redirect /something-complex to /not-root": {"/something-complex", "/not-root", "~* /something-complex", ` @@ -53,8 +53,8 @@ var ( subs_filter '' '' r; `, true}, "redirect /something to / and rewrite": {"/something", "/", "~* /something", ` - rewrite /something / break; rewrite /something/(.*) /$1 break; + rewrite /something / break; proxy_pass http://upstream-name; subs_filter '' '' r; subs_filter '' '' r;