|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
[[ $c := merge .diagrams . -]]
|
|
|
|
|
job [[ .diagrams.instance | toJSON ]] {
|
|
|
|
|
job [[ .instance | toJSON ]] {
|
|
|
|
|
|
|
|
|
|
[[ template "common/job_start.tpl" $c ]]
|
|
|
|
|
|
|
|
|
@ -9,7 +9,7 @@ job [[ .diagrams.instance | toJSON ]] {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
service {
|
|
|
|
|
name = "[[ .diagrams.instance ]][[ .consul.suffix ]]"
|
|
|
|
|
name = "[[ .instance ]][[ .consul.suffix ]]"
|
|
|
|
|
port = 8282
|
|
|
|
|
|
|
|
|
|
[[ template "common/connect.tpl" $c ]]
|
|
|
|
@ -31,21 +31,21 @@ job [[ .diagrams.instance | toJSON ]] {
|
|
|
|
|
"[[ $c.traefik.instance ]].enable=[[ $c.traefik.enabled ]]",
|
|
|
|
|
|
|
|
|
|
# Define a middleware to set custom CSP headers
|
|
|
|
|
"[[ $c.traefik.instance ]].http.middlewares.[[ .diagrams.instance ]]-headers[[ .consul.suffix ]].headers.contentsecuritypolicy=[[ range $k, $v := $c.traefik.csp ]][[ $k ]] [[ $v ]];[[ end ]]",
|
|
|
|
|
"[[ $c.traefik.instance ]].http.middlewares.[[ .instance ]]-headers[[ .consul.suffix ]].headers.contentsecuritypolicy=[[ range $k, $v := $c.traefik.csp ]][[ $k ]] [[ $v ]];[[ end ]]",
|
|
|
|
|
|
|
|
|
|
[[- if not (regexp.Match "^/?$" (urlParse $c.public_url).Path) ]]
|
|
|
|
|
# Diagrams exposed by traefik on a subpath. Define a middleware to strip the prefix before passing the request to the backend
|
|
|
|
|
"[[ $c.traefik.instance ]].http.middlewares.[[ .diagrams.instance ]]-prefix[[ .consul.suffix ]].stripprefix.prefixes=[[ (urlParse .diagrams.public_url).Path ]]",
|
|
|
|
|
"[[ $c.traefik.instance ]].http.middlewares.[[ .instance ]]-prefix[[ .consul.suffix ]].stripprefix.prefixes=[[ (urlParse .diagrams.public_url).Path ]]",
|
|
|
|
|
[[- end ]]
|
|
|
|
|
|
|
|
|
|
# Main app router
|
|
|
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .diagrams.instance ]][[ .consul.suffix ]].rule=Host(`[[ (urlParse $c.public_url).Hostname ]]`)
|
|
|
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .instance ]][[ .consul.suffix ]].rule=Host(`[[ (urlParse $c.public_url).Hostname ]]`)
|
|
|
|
|
[[- if not (regexp.Match "^/?$" (urlParse $c.public_url).Path) ]] && PathPrefix(`[[ (urlParse $c.public_url).Path ]]`)[[ end ]]",
|
|
|
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .diagrams.instance ]][[ .consul.suffix ]].entrypoints=[[ join $c.traefik.entrypoints "," ]]",
|
|
|
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .instance ]][[ .consul.suffix ]].entrypoints=[[ join $c.traefik.entrypoints "," ]]",
|
|
|
|
|
[[- if not (regexp.Match "^/?$" (urlParse $c.public_url).Path) ]]
|
|
|
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .diagrams.instance ]][[ .consul.suffix ]].middlewares=[[ .diagrams.instance ]]-prefix[[ $c.consul.suffix ]],[[ .diagrams.instance ]]-headers[[ .consul.suffix ]],[[ template "common/traefik_middlewares.tpl" $c.traefik ]]",
|
|
|
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .instance ]][[ .consul.suffix ]].middlewares=[[ .instance ]]-prefix[[ $c.consul.suffix ]],[[ .instance ]]-headers[[ .consul.suffix ]],[[ template "common/traefik_middlewares.tpl" $c.traefik ]]",
|
|
|
|
|
[[- else ]]
|
|
|
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .diagrams.instance ]][[ .consul.suffix ]].middlewares=[[ .diagrams.instance ]]-headers[[ .consul.suffix ]],[[ template "common/traefik_middlewares.tpl" $c.traefik ]]",
|
|
|
|
|
"[[ $c.traefik.instance ]].http.routers.[[ .instance ]][[ .consul.suffix ]].middlewares=[[ .instance ]]-headers[[ .consul.suffix ]],[[ template "common/traefik_middlewares.tpl" $c.traefik ]]",
|
|
|
|
|
[[- end ]]
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|