Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for rewrite #14

Open
wants to merge 1 commit into
base: controller-v0.43
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions internal/ingress/controller/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,15 @@ func enforceRegexModifier(input interface{}) bool {

// buildLocation produces the location string, if the ingress has redirects
// (specified through the nginx.ingress.kubernetes.io/rewrite-target annotation)
func buildLocation(input interface{}, enforceRegex bool) string {
func buildLocation(input interface{}, allEnforceRegex bool) string {
location, ok := input.(*ingress.Location)
if !ok {
klog.Errorf("expected an '*ingress.Location' type but %T was returned", input)
return slash
}

enforceRegex := needsRewrite(location) || location.Rewrite.UseRegex

path := location.Path
if enforceRegex {
return fmt.Sprintf(`~* "^%s"`, path)
Expand All @@ -410,8 +412,14 @@ func buildLocation(input interface{}, enforceRegex bool) string {
if location.PathType != nil && *location.PathType == networkingv1beta1.PathTypeExact {
return fmt.Sprintf(`= %s`, path)
}
prefix := ""
if allEnforceRegex {
// if some location other than this is regex, then use "^~ ". so that has a high priority.
prefix = "^~ "

}

return path
return prefix + path
}

func buildAuthLocation(input interface{}, globalExternalAuthURL string) string {
Expand Down