diff --git a/internal/ingress/controller/template/template.go b/internal/ingress/controller/template/template.go index 56098a505..8a1a7fee7 100644 --- a/internal/ingress/controller/template/template.go +++ b/internal/ingress/controller/template/template.go @@ -406,7 +406,7 @@ func buildLocation(input interface{}, enforceRegex bool) string { } if location.PathType != nil && *location.PathType == networkingv1beta1.PathTypeExact { - return fmt.Sprintf(`= %s`, path) + return fmt.Sprintf(`~ ^%s$`, path) } return path diff --git a/test/e2e/ingress/pathtype_exact.go b/test/e2e/ingress/pathtype_exact.go index c3be0d327..4edeff1b5 100644 --- a/test/e2e/ingress/pathtype_exact.go +++ b/test/e2e/ingress/pathtype_exact.go @@ -60,7 +60,7 @@ var _ = framework.IngressNginxDescribe("[Ingress] [PathType] exact", func() { f.WaitForNginxServer(host, func(server string) bool { return strings.Contains(server, host) && - strings.Contains(server, "location = /exact") && + strings.Contains(server, "location ~ ^/exact$") && strings.Contains(server, "location /exact") }) @@ -98,7 +98,7 @@ var _ = framework.IngressNginxDescribe("[Ingress] [PathType] exact", func() { f.WaitForNginxServer(host, func(server string) bool { return strings.Contains(server, host) && - strings.Contains(server, "location = /exact") && + strings.Contains(server, "location ~ ^/exact$") && strings.Contains(server, "location /exact") })