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

Commit

Permalink
Merge pull request #1136 from aledbf/fix-rewrite-order
Browse files Browse the repository at this point in the history
[nginx-ingress-controller]: Fix nginx rewrite rule order
  • Loading branch information
bprashanth authored Jun 10, 2016
2 parents 679164a + 6596931 commit cefb6c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
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

0 comments on commit cefb6c1

Please sign in to comment.