Skip to content
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