Skip to content

Commit

Permalink
Fix rewrite-target Annotation behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
dtomcej authored and traefiker committed Jul 9, 2018
1 parent ba20464 commit 9374d6b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion provider/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ func getRuleForPath(pa extensionsv1beta1.HTTPIngressPath, i *extensionsv1beta1.I
if pathReplaceAnnotation != "" {
return "", fmt.Errorf("rewrite-target must not be used together with annotation %q", pathReplaceAnnotation)
}
rules = append(rules, ruleTypeReplacePath+":"+rewriteTarget)
rewriteTargetRule := fmt.Sprintf("ReplacePathRegex: ^%s/(.*) %s/$1", pa.Path, strings.TrimRight(rewriteTarget, "/"))
rules = append(rules, rewriteTargetRule)
pathReplaceAnnotation = annotationKubernetesRewriteTarget
}

Expand Down
2 changes: 1 addition & 1 deletion provider/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ rateset:
frontend("rewrite/api",
passHostHeader(),
routes(
route("/api", "PathPrefix:/api;ReplacePath:/"),
route("/api", "PathPrefix:/api;ReplacePathRegex: ^/api/(.*) /$1"),
route("rewrite", "Host:rewrite")),
),
frontend("error-pages/errorpages",
Expand Down

0 comments on commit 9374d6b

Please sign in to comment.