Add getPrefixes to get string array of PathPrefixes
Marathon label traefik.prefixes can be used to specify what prefixes to use. New example marathon-prefix.tmpl to take advantage of this new mechanism.
This commit is contained in:
parent
cae02b02ac
commit
bc94ace7d3
3 changed files with 36 additions and 0 deletions
27
providerTemplates/marathon-prefix.tmpl
Normal file
27
providerTemplates/marathon-prefix.tmpl
Normal file
|
@ -0,0 +1,27 @@
|
|||
{{$apps := .Applications}}
|
||||
[backends]{{range .Tasks}}
|
||||
[backends.backend{{.AppID | replace "/" "-"}}.servers.server-{{.ID | replace "." "-"}}]
|
||||
url = "http://{{.Host}}:{{getPort .}}"
|
||||
{{$appID := .AppID}}
|
||||
{{range $apps}}
|
||||
{{if eq $appID .ID}}
|
||||
weight = {{getWeight .}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
[frontends]{{ range $app := .Applications}}
|
||||
{{range $prefix := getPrefixes .}}
|
||||
[frontends.frontend{{$app.ID | replace "/" "-"}}{{$prefix | replace "/" "-"}}]
|
||||
backend = "backend{{$app.ID | replace "/" "-"}}"
|
||||
[frontends.frontend-{{getHost $app | replace "/" "-"}}{{$prefix | replace "/" "-"}}.routes.route-prefix{{$prefix | replace "/" "-"}}]
|
||||
rule = "PathPrefix"
|
||||
value = "{{.}}"
|
||||
{{else}}
|
||||
[frontends.frontend{{.ID | replace "/" "-"}}]
|
||||
backend = "backend{{.ID | replace "/" "-"}}"
|
||||
[frontends.frontend-{{getHost $app | replace "/" "-"}}.routes.route-host-{{getHost $app | replace "/" "-"}}]
|
||||
rule = "Host"
|
||||
value = "{{getHost $app | replace "/" "-"}}.{{$.Domain}}"
|
||||
{{end}}
|
||||
{{end}}
|
Loading…
Add table
Add a link
Reference in a new issue