Handle cases with a rule but no public_url

This commit is contained in:
Daniel Berteaud 2024-01-29 11:35:11 +01:00
parent 5903329a6d
commit 9f388a54d8

View File

@ -26,10 +26,10 @@
[[- end ]]
[[- $middlewares := coll.Slice ]]
[[- if and (has . "public_url") (eq $proto "http") ]]
[[- if eq $proto "http" ]]
[[- if has .traefik "rule" ]]
"[[ .traefik.instance ]].http.routers.[[ $router ]].rule=[[ .traefik.rule ]]",
[[- else if .traefik.auto_rule ]]
[[- else if and (has . "public_url") (.traefik.auto_rule) ]]
"[[ .traefik.instance ]].http.routers.[[ $router ]].rule=Host(`[[ (urlParse .public_url).Hostname ]]`)
[[- if not (regexp.Match "^/?$" (urlParse .public_url).Path) ]] && PathPrefix(`[[ (urlParse .public_url).Path | regexp.Replace "^//" "/" ]]`)[[ end ]]",
[[- end ]]