Skip to content

Commit

Permalink
Allow empty path with App-root annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
dtomcej authored and jacksgt committed Jan 4, 2019
1 parent 920dcdd commit 389cb86
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion provider/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ func loadAuthTLSSecret(namespace, secretName string, k8sClient Client) (string,
func getFrontendRedirect(i *extensionsv1beta1.Ingress, baseName, path string) *types.Redirect {
permanent := getBoolValue(i.Annotations, annotationKubernetesRedirectPermanent, false)

if appRoot := getStringValue(i.Annotations, annotationKubernetesAppRoot, ""); appRoot != "" && path == "/" {
if appRoot := getStringValue(i.Annotations, annotationKubernetesAppRoot, ""); appRoot != "" && (path == "/" || path == "") {
return &types.Redirect{
Regex: fmt.Sprintf("%s$", baseName),
Replacement: fmt.Sprintf("%s/%s", strings.TrimRight(baseName, "/"), strings.TrimLeft(appRoot, "/")),
Expand Down
24 changes: 24 additions & 0 deletions provider/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,18 @@ rateset:
),
),
),
buildIngress(
iNamespace("testing"),
iAnnotation(annotationKubernetesAppRoot, "/root"),
iRules(
iRule(
iHost("root3"),
iPaths(
onePath(iBackend("service1", intstr.FromInt(80))),
),
),
),
),
buildIngress(
iNamespace("testing"),
iAnnotation(annotationKubernetesIngressClass, "traefik"),
Expand Down Expand Up @@ -1503,6 +1515,11 @@ rateset:
servers(),
lbMethod("wrr"),
),
backend("root3",
servers(
server("http://example.com", weight(1))),
lbMethod("wrr"),
),
backend("protocol/valid",
servers(
server("h2c://example.com", weight(1)),
Expand Down Expand Up @@ -1658,6 +1675,13 @@ rateset:
route("root", "Host:root"),
),
),
frontend("root3",
passHostHeader(),
redirectRegex("root3$", "root3/root"),
routes(
route("root3", "Host:root3"),
),
),
frontend("protocol/valid",
passHostHeader(),
routes(
Expand Down

0 comments on commit 389cb86

Please sign in to comment.