From d15a17b6347b867014c37f4bdb40664e85733d77 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 20 Jan 2017 14:16:05 +0100 Subject: [PATCH] Allow for wildcards in k8s ingress host, fixes #792 (#1029) --- provider/kubernetes.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/provider/kubernetes.go b/provider/kubernetes.go index 42a01d2f6..0ea5799a3 100644 --- a/provider/kubernetes.go +++ b/provider/kubernetes.go @@ -125,9 +125,15 @@ func (provider *Kubernetes) loadIngresses(k8sClient k8s.Client) (*types.Configur } } if len(r.Host) > 0 { + rule := "Host:" + r.Host + + if strings.Contains(r.Host, "*") { + rule = "HostRegexp:" + strings.Replace(r.Host, "*", "{subdomain:[A-Za-z0-9-_]+}", 1) + } + if _, exists := templateObjects.Frontends[r.Host+pa.Path].Routes[r.Host]; !exists { templateObjects.Frontends[r.Host+pa.Path].Routes[r.Host] = types.Route{ - Rule: "Host:" + r.Host, + Rule: rule, } } }