Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

[nginx-ingress-controller]: Fix nginx rewrite rule order #1136

Merged
merged 1 commit into from
Jun 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ingress/controllers/nginx/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions ingress/controllers/nginx/nginx/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand Down
4 changes: 2 additions & 2 deletions ingress/controllers/nginx/nginx/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", `
Expand All @@ -53,8 +53,8 @@ var (
subs_filter '<HEAD(.*)>' '<HEAD$1><base href="$scheme://$server_name/jenkins/">' 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 '<head(.*)>' '<head$1><base href="$scheme://$server_name/">' r;
subs_filter '<HEAD(.*)>' '<HEAD$1><base href="$scheme://$server_name/">' r;
Expand Down