diff --git a/templates/traefik.yml.tpl b/templates/traefik.yml.tpl index 5555ff0..e074b86 100644 --- a/templates/traefik.yml.tpl +++ b/templates/traefik.yml.tpl @@ -12,25 +12,28 @@ entryPoints: [[- range $name, $def := .traefik.entrypoints ]] + [[- if or (not (has $def "enabled")) ($def.enabled) ]] [[ $name ]]: address: ":{{ env "NOMAD_PORT_[[ $name | regexp.Replace "[\\.\\-]" "_" ]]" }}[[ if has $def "protocol" ]]/[[ $def.protocol ]][[ end ]]" -[[- if gt (len $.traefik.trusted_proxies) 0 ]] + [[- if gt (len $.traefik.trusted_proxies) 0 ]] proxyProtocol: trustedIPs:[[ range $idx, $ip := $.traefik.trusted_proxies ]] - - [[ $ip ]][[ end ]] - [[- if has $def "http" ]] + - [[ $ip ]] + [[ end ]] + [[- if has $def "http" ]] http: [[ $def.http | toYAML | indent 6 ]] - [[- end ]] + [[- end ]] transport: lifeCycle: requestAcceptGraceTimeout: 4 -[[- if and (has $def "middlewares") (gt (len $def.middlewares)) ]] + [[- if and (has $def "middlewares") (gt (len $def.middlewares)) ]] middlewares: -[[- range $def.middlewares ]] + [[- range $def.middlewares ]] - [[ . ]] -[[- end ]] -[[- end ]] + [[- end ]] + [[- end ]] + [[- end ]] [[- end ]] [[- end ]] diff --git a/traefik.nomad.hcl b/traefik.nomad.hcl index b6bc2b7..83e9f07 100644 --- a/traefik.nomad.hcl +++ b/traefik.nomad.hcl @@ -11,18 +11,18 @@ job [[ .traefik.instance | toJSON ]] { network { mode = "bridge" - [[- range $name, $def := .traefik.entrypoints ]] - [[- if or (not (has $def "enabled")) ($def.enabled) ]] +[[- range $name, $def := .traefik.entrypoints ]] + [[- if or (not (has $def "enabled")) ($def.enabled) ]] port "[[ $name ]]" { - [[- if has $def "static" ]] + [[- if has $def "static" ]] static = [[ $def.static ]] - [[- end ]] - [[- if has $def "to" ]] + [[- end ]] + [[- if has $def "to" ]] to = [[ $def.to ]] - [[- end ]] + [[- end ]] } - [[- end ]] - [[- end ]] + [[- end ]] +[[- end ]] port "metrics" {} }