mirror of
https://github.com/containous/traefik.git
synced 2024-12-23 17:34:13 +03:00
homogenization of templates: Marathon
This commit is contained in:
parent
b60edd9ee9
commit
870c0b5cf4
@ -1081,195 +1081,171 @@ func templatesKvTmpl() (*asset, error) {
|
|||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var _templatesMarathonTmpl = []byte(`{{$apps := .Applications}}
|
var _templatesMarathonTmpl = []byte(`{{ $apps := .Applications }}
|
||||||
|
|
||||||
[backends]
|
[backends]
|
||||||
{{range $app := $apps}}
|
{{range $app := $apps }}
|
||||||
{{range $serviceIndex, $serviceName := getServiceNames $app}}
|
{{range $serviceIndex, $serviceName := getServiceNames $app }}
|
||||||
|
{{ $backendName := getBackend $app $serviceName}}
|
||||||
|
|
||||||
[backends."{{getBackend $app $serviceName }}"]
|
[backends."{{ $backendName }}"]
|
||||||
|
|
||||||
{{ if hasCircuitBreakerLabels $app }}
|
{{ $circuitBreaker := getCircuitBreaker $app }}
|
||||||
[backends."{{getBackend $app $serviceName }}".circuitBreaker]
|
{{if $circuitBreaker }}
|
||||||
expression = "{{getCircuitBreakerExpression $app }}"
|
[backends."{{ $backendName }}".circuitBreaker]
|
||||||
|
expression = "{{ $circuitBreaker.Expression }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ if hasLoadBalancerLabels $app }}
|
{{ $loadBalancer := getLoadBalancer $app }}
|
||||||
[backends."{{getBackend $app $serviceName }}".loadBalancer]
|
{{if $loadBalancer }}
|
||||||
method = "{{getLoadBalancerMethod $app }}"
|
[backends."{{ $backendName }}".loadBalancer]
|
||||||
sticky = {{getSticky $app}}
|
method = "{{ $loadBalancer.Method }}"
|
||||||
{{if hasStickinessLabel $app}}
|
sticky = {{ $loadBalancer.Sticky }}
|
||||||
[backends."{{getBackend $app $serviceName }}".loadBalancer.stickiness]
|
{{if $loadBalancer.Stickiness }}
|
||||||
cookieName = "{{getStickinessCookieName $app}}"
|
[backends."{{ $backendName }}".loadBalancer.stickiness]
|
||||||
|
cookieName = "{{ $loadBalancer.Stickiness.CookieName }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ if hasMaxConnLabels $app }}
|
{{ $maxConn := getMaxConn $app }}
|
||||||
[backends."{{getBackend $app $serviceName }}".maxConn]
|
{{if $maxConn }}
|
||||||
amount = {{getMaxConnAmount $app }}
|
[backends."{{ $backendName }}".maxConn]
|
||||||
extractorFunc = "{{getMaxConnExtractorFunc $app }}"
|
extractorFunc = "{{ $maxConn.ExtractorFunc }}"
|
||||||
|
amount = {{ $maxConn.Amount }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ if hasHealthCheckLabels $app }}
|
{{ $healthCheck := getHealthCheck $app }}
|
||||||
[backends."{{getBackend $app $serviceName }}".healthCheck]
|
{{if $healthCheck }}
|
||||||
path = "{{getHealthCheckPath $app }}"
|
[backends."{{ $backendName }}".healthCheck]
|
||||||
port = {{getHealthCheckPort $app}}
|
path = "{{ $healthCheck.Path }}"
|
||||||
interval = "{{getHealthCheckInterval $app }}"
|
port = {{ $healthCheck.Port }}
|
||||||
|
interval = "{{ $healthCheck.Interval }}"
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{range $serverName, $server := getServers $app $serviceName }}
|
||||||
|
[backends."{{ $backendName }}".servers."{{ $serverName }}"]
|
||||||
|
url = "{{ $server.URL }}"
|
||||||
|
weight = {{ $server.Weight }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{range $task := $app.Tasks}}
|
|
||||||
{{range $serviceIndex, $serviceName := getServiceNames $app}}
|
|
||||||
|
|
||||||
[backends."{{getBackend $app $serviceName}}".servers."server-{{$task.ID | replace "." "-"}}{{getServiceNameSuffix $serviceName }}"]
|
|
||||||
url = "{{getProtocol $app $serviceName}}://{{getBackendServer $task $app}}:{{getPort $task $app $serviceName}}"
|
|
||||||
weight = {{getWeight $app $serviceName}}
|
|
||||||
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
[frontends]
|
[frontends]
|
||||||
{{range $app := $apps}}
|
{{range $app := $apps }}
|
||||||
{{range $serviceIndex, $serviceName := getServiceNames .}}
|
{{range $serviceIndex, $serviceName := getServiceNames $app }}
|
||||||
|
{{ $frontendName := getFrontendName $app $serviceName }}
|
||||||
|
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}"]
|
[frontends."{{ $frontendName }}"]
|
||||||
backend = "{{getBackend $app $serviceName}}"
|
backend = "{{ getBackend $app $serviceName }}"
|
||||||
priority = {{getPriority $app $serviceName}}
|
priority = {{ getPriority $app $serviceName }}
|
||||||
passHostHeader = {{getPassHostHeader $app $serviceName}}
|
passHostHeader = {{ getPassHostHeader $app $serviceName }}
|
||||||
passTLSCert = {{getPassTLSCert $app $serviceName}}
|
passTLSCert = {{ getPassTLSCert $app $serviceName }}
|
||||||
|
|
||||||
entryPoints = [{{range getEntryPoints $app $serviceName}}
|
entryPoints = [{{range getEntryPoints $app $serviceName }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
|
|
||||||
{{if getWhitelistSourceRange $app $serviceName}}
|
{{ $whitelistSourceRange := getWhitelistSourceRange $app $serviceName }}
|
||||||
whitelistSourceRange = [{{range getWhitelistSourceRange $app $serviceName}}
|
{{if $whitelistSourceRange }}
|
||||||
|
whitelistSourceRange = [{{range $whitelistSourceRange }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
basicAuth = [{{range getBasicAuth $app $serviceName}}
|
basicAuth = [{{range getBasicAuth $app $serviceName }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
|
|
||||||
{{if hasRedirect $app $serviceName}}
|
{{ $redirect := getRedirect $app $serviceName }}
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".redirect]
|
{{if $redirect }}
|
||||||
entryPoint = "{{getRedirectEntryPoint $app $serviceName}}"
|
[frontends."{{ $frontendName }}".redirect]
|
||||||
regex = "{{getRedirectRegex $app $serviceName}}"
|
entryPoint = "{{ $redirect.EntryPoint }}"
|
||||||
replacement = "{{getRedirectReplacement $app $serviceName}}"
|
regex = "{{ $redirect.Regex }}"
|
||||||
|
replacement = "{{ $redirect.Replacement }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ if hasErrorPages $app $serviceName }}
|
{{ $errorPages := getErrorPages $app $serviceName }}
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".errors]
|
{{if $errorPages }}
|
||||||
{{ range $pageName, $page := getErrorPages $app $serviceName }}
|
[frontends."{{ $frontendName }}".errors]
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".errors.{{ $pageName }}]
|
{{range $pageName, $page := $errorPages }}
|
||||||
status = [{{range $page.Status}}
|
[frontends."{{ $frontendName }}".errors.{{ $pageName }}]
|
||||||
"{{.}}",
|
status = [{{range $page.Status }}
|
||||||
{{end}}]
|
"{{.}}",
|
||||||
backend = "{{$page.Backend}}"
|
{{end}}]
|
||||||
query = "{{$page.Query}}"
|
backend = "{{ $page.Backend }}"
|
||||||
|
query = "{{ $page.Query }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ if hasRateLimits $app $serviceName }}
|
{{ $rateLimit := getRateLimit $app $serviceName }}
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".rateLimit]
|
{{if $rateLimit }}
|
||||||
extractorFunc = "{{ getRateLimitsExtractorFunc $app $serviceName }}"
|
[frontends."{{ $frontendName }}".rateLimit]
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".rateLimit.rateSet]
|
extractorFunc = "{{ $rateLimit.ExtractorFunc }}"
|
||||||
{{ range $limitName, $rateLimit := getRateLimits $app $serviceName }}
|
[frontends."{{ $frontendName }}".rateLimit.rateSet]
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".rateLimit.rateSet.{{ $limitName }}]
|
{{ range $limitName, $limit := $rateLimit.RateSet }}
|
||||||
period = "{{ $rateLimit.Period }}"
|
[frontends."{{ $frontendName }}".rateLimit.rateSet.{{ $limitName }}]
|
||||||
average = {{ $rateLimit.Average }}
|
period = "{{ $limit.Period }}"
|
||||||
burst = {{ $rateLimit.Burst }}
|
average = {{ $limit.Average }}
|
||||||
|
burst = {{ $limit.Burst }}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasHeaders $app $serviceName }}
|
{{ $headers := getHeaders $app $serviceName }}
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".headers]
|
{{if $headers }}
|
||||||
{{if hasSSLRedirectHeaders $app $serviceName}}
|
[frontends."{{ $frontendName }}".headers]
|
||||||
SSLRedirect = {{getSSLRedirectHeaders $app $serviceName}}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
{{end}}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
{{if hasSSLTemporaryRedirectHeaders $app $serviceName}}
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
SSLTemporaryRedirect = {{getSSLTemporaryRedirectHeaders $app $serviceName}}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
{{end}}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
{{if hasSSLHostHeaders $app $serviceName}}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
SSLHost = "{{getSSLHostHeaders $app $serviceName}}"
|
ForceSTSHeader = {{ $headers.ForceSTSHeader }}
|
||||||
{{end}}
|
FrameDeny = {{ $headers.FrameDeny }}
|
||||||
{{if hasSTSSecondsHeaders $app $serviceName}}
|
CustomFrameOptionsValue = "{{ $headers.CustomFrameOptionsValue }}"
|
||||||
STSSeconds = {{getSTSSecondsHeaders $app $serviceName}}
|
ContentTypeNosniff = {{ $headers.ContentTypeNosniff }}
|
||||||
{{end}}
|
BrowserXSSFilter = {{ $headers.BrowserXSSFilter }}
|
||||||
{{if hasSTSIncludeSubdomainsHeaders $app $serviceName}}
|
ContentSecurityPolicy = "{{ $headers.ContentSecurityPolicy }}"
|
||||||
STSIncludeSubdomains = {{getSTSIncludeSubdomainsHeaders $app $serviceName}}
|
PublicKey = "{{ $headers.PublicKey }}"
|
||||||
{{end}}
|
ReferrerPolicy = "{{ $headers.ReferrerPolicy }}"
|
||||||
{{if hasSTSPreloadHeaders $app $serviceName}}
|
IsDevelopment = {{ $headers.IsDevelopment }}
|
||||||
STSPreload = {{getSTSPreloadHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
{{if hasForceSTSHeaderHeaders $app $serviceName}}
|
|
||||||
ForceSTSHeader = {{getForceSTSHeaderHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
{{if hasFrameDenyHeaders $app $serviceName}}
|
|
||||||
FrameDeny = {{getFrameDenyHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
{{if hasCustomFrameOptionsValueHeaders $app $serviceName}}
|
|
||||||
CustomFrameOptionsValue = "{{getCustomFrameOptionsValueHeaders $app $serviceName}}"
|
|
||||||
{{end}}
|
|
||||||
{{if hasContentTypeNosniffHeaders $app $serviceName}}
|
|
||||||
ContentTypeNosniff = {{getContentTypeNosniffHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
{{if hasBrowserXSSFilterHeaders $app $serviceName}}
|
|
||||||
BrowserXSSFilter = {{getBrowserXSSFilterHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
{{if hasContentSecurityPolicyHeaders $app $serviceName}}
|
|
||||||
ContentSecurityPolicy = "{{getContentSecurityPolicyHeaders $app $serviceName}}"
|
|
||||||
{{end}}
|
|
||||||
{{if hasPublicKeyHeaders $app $serviceName}}
|
|
||||||
PublicKey = "{{getPublicKeyHeaders $app $serviceName}}"
|
|
||||||
{{end}}
|
|
||||||
{{if hasReferrerPolicyHeaders $app $serviceName}}
|
|
||||||
ReferrerPolicy = "{{getReferrerPolicyHeaders $app $serviceName}}"
|
|
||||||
{{end}}
|
|
||||||
{{if hasIsDevelopmentHeaders $app $serviceName}}
|
|
||||||
IsDevelopment = {{getIsDevelopmentHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{if hasAllowedHostsHeaders $app $serviceName}}
|
{{if $headers.AllowedHosts }}
|
||||||
AllowedHosts = [{{range getAllowedHostsHeaders $app $serviceName}}
|
AllowedHosts = [{{range $headers.AllowedHosts }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasHostsProxyHeaders $app $serviceName}}
|
{{if $headers.HostsProxyHeaders }}
|
||||||
HostsProxyHeaders = [{{range getHostsProxyHeaders $app $serviceName}}
|
HostsProxyHeaders = [{{range $headers.HostsProxyHeaders }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasRequestHeaders $app $serviceName}}
|
{{if $headers.CustomRequestHeaders }}
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".headers.customRequestHeaders]
|
[frontends."{{ $frontendName }}".headers.customRequestHeaders]
|
||||||
{{range $k, $v := getRequestHeaders $app $serviceName}}
|
{{range $k, $v := $headers.CustomRequestHeaders }}
|
||||||
{{$k}} = "{{$v}}"
|
{{$k}} = "{{$v}}"
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if $headers.CustomResponseHeaders }}
|
||||||
|
[frontends."{{ $frontendName }}".headers.customResponseHeaders]
|
||||||
|
{{range $k, $v := $headers.CustomResponseHeaders }}
|
||||||
|
{{$k}} = "{{$v}}"
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if $headers.SSLProxyHeaders }}
|
||||||
|
[frontends."{{ $frontendName }}".headers.SSLProxyHeaders]
|
||||||
|
{{range $k, $v := $headers.SSLProxyHeaders }}
|
||||||
|
{{$k}} = "{{$v}}"
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasResponseHeaders $app $serviceName}}
|
[frontends."{{ $frontendName }}".routes."route-host{{ $app.ID | replace "/" "-" }}{{ getServiceNameSuffix $serviceName }}"]
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".headers.customResponseHeaders]
|
rule = "{{ getFrontendRule $app $serviceName }}"
|
||||||
{{range $k, $v := getResponseHeaders $app $serviceName}}
|
|
||||||
{{$k}} = "{{$v}}"
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{if hasSSLProxyHeaders $app $serviceName}}
|
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".headers.SSLProxyHeaders]
|
|
||||||
{{range $k, $v := getSSLProxyHeaders $app $serviceName}}
|
|
||||||
{{$k}} = "{{$v}}"
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".routes."route-host{{$app.ID | replace "/" "-"}}{{getServiceNameSuffix $serviceName }}"]
|
|
||||||
rule = "{{getFrontendRule $app $serviceName}}"
|
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -93,6 +93,14 @@ func GetBoolValue(labels map[string]string, labelName string, defaultValue bool)
|
|||||||
return defaultValue
|
return defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetBoolValueP get bool value associated to a label
|
||||||
|
func GetBoolValueP(labels *map[string]string, labelName string, defaultValue bool) bool {
|
||||||
|
if labels == nil {
|
||||||
|
return defaultValue
|
||||||
|
}
|
||||||
|
return GetBoolValue(*labels, labelName, defaultValue)
|
||||||
|
}
|
||||||
|
|
||||||
// GetIntValue get int value associated to a label
|
// GetIntValue get int value associated to a label
|
||||||
func GetIntValue(labels map[string]string, labelName string, defaultValue int) int {
|
func GetIntValue(labels map[string]string, labelName string, defaultValue int) int {
|
||||||
if rawValue, ok := labels[labelName]; ok {
|
if rawValue, ok := labels[labelName]; ok {
|
||||||
@ -229,6 +237,14 @@ func HasPrefix(labels map[string]string, prefix string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasPrefixP Check if a value is associated to a less one label with a prefix
|
||||||
|
func HasPrefixP(labels *map[string]string, prefix string) bool {
|
||||||
|
if labels == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return HasPrefix(*labels, prefix)
|
||||||
|
}
|
||||||
|
|
||||||
// FindServiceSubmatch split service label
|
// FindServiceSubmatch split service label
|
||||||
func FindServiceSubmatch(name string) []string {
|
func FindServiceSubmatch(name string) []string {
|
||||||
matches := ServicesPropertiesRegexp.FindStringSubmatch(name)
|
matches := ServicesPropertiesRegexp.FindStringSubmatch(name)
|
||||||
|
@ -50,7 +50,7 @@ func constraint(value string) func(*marathon.Application) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func labelWithService(key, value string, serviceName string) func(*marathon.Application) {
|
func withServiceLabel(key, value string, serviceName string) func(*marathon.Application) {
|
||||||
if len(serviceName) == 0 {
|
if len(serviceName) == 0 {
|
||||||
panic("serviceName can not be empty")
|
panic("serviceName can not be empty")
|
||||||
}
|
}
|
||||||
@ -121,20 +121,35 @@ func readinessCheckResult(taskID string, ready bool) func(*marathon.Application)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func withTasks(tasks ...marathon.Task) func(*marathon.Application) {
|
||||||
|
return func(application *marathon.Application) {
|
||||||
|
for _, task := range tasks {
|
||||||
|
tu := task
|
||||||
|
application.Tasks = append(application.Tasks, &tu)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Functions related to building tasks.
|
// Functions related to building tasks.
|
||||||
|
|
||||||
func task(ops ...func(*marathon.Task)) marathon.Task {
|
func task(ops ...func(*marathon.Task)) marathon.Task {
|
||||||
t := marathon.Task{
|
t := &marathon.Task{
|
||||||
ID: testTaskName,
|
ID: testTaskName,
|
||||||
// The vast majority of tests expect the task state to be TASK_RUNNING.
|
// The vast majority of tests expect the task state to be TASK_RUNNING.
|
||||||
State: string(taskStateRunning),
|
State: string(taskStateRunning),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, op := range ops {
|
for _, op := range ops {
|
||||||
op(&t)
|
op(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
return t
|
return *t
|
||||||
|
}
|
||||||
|
|
||||||
|
func withTaskID(id string) func(*marathon.Task) {
|
||||||
|
return func(task *marathon.Task) {
|
||||||
|
task.ID = id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func localhostTask(ops ...func(*marathon.Task)) marathon.Task {
|
func localhostTask(ops ...func(*marathon.Task)) marathon.Task {
|
||||||
|
@ -17,6 +17,8 @@ import (
|
|||||||
"github.com/gambol99/go-marathon"
|
"github.com/gambol99/go-marathon"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const defaultService = ""
|
||||||
|
|
||||||
func (p *Provider) buildConfiguration() *types.Configuration {
|
func (p *Provider) buildConfiguration() *types.Configuration {
|
||||||
var MarathonFuncMap = template.FuncMap{
|
var MarathonFuncMap = template.FuncMap{
|
||||||
"getBackend": p.getBackend,
|
"getBackend": p.getBackend,
|
||||||
@ -24,87 +26,60 @@ func (p *Provider) buildConfiguration() *types.Configuration {
|
|||||||
"getSubDomain": p.getSubDomain, // see https://github.com/containous/traefik/pull/1693
|
"getSubDomain": p.getSubDomain, // see https://github.com/containous/traefik/pull/1693
|
||||||
|
|
||||||
// Backend functions
|
// Backend functions
|
||||||
"getBackendServer": p.getBackendServer,
|
"getBackendServer": p.getBackendServer,
|
||||||
"getPort": getPort,
|
"getPort": getPort,
|
||||||
"getWeight": getFuncStringService(label.SuffixWeight, label.DefaultWeight),
|
"getCircuitBreaker": getCircuitBreaker,
|
||||||
"getProtocol": getFuncStringService(label.SuffixProtocol, label.DefaultProtocol),
|
"getLoadBalancer": getLoadBalancer,
|
||||||
"hasCircuitBreakerLabels": hasFunc(label.TraefikBackendCircuitBreakerExpression),
|
"getMaxConn": getMaxConn,
|
||||||
|
"getHealthCheck": getHealthCheck,
|
||||||
|
"getServers": p.getServers,
|
||||||
|
|
||||||
|
// TODO Deprecated [breaking]
|
||||||
|
"getWeight": getFuncIntService(label.SuffixWeight, label.DefaultWeightInt),
|
||||||
|
// TODO Deprecated [breaking]
|
||||||
|
"getProtocol": getFuncStringService(label.SuffixProtocol, label.DefaultProtocol),
|
||||||
|
// TODO Deprecated [breaking]
|
||||||
|
"hasCircuitBreakerLabels": hasFunc(label.TraefikBackendCircuitBreakerExpression),
|
||||||
|
// TODO Deprecated [breaking]
|
||||||
"getCircuitBreakerExpression": getFuncString(label.TraefikBackendCircuitBreakerExpression, label.DefaultCircuitBreakerExpression),
|
"getCircuitBreakerExpression": getFuncString(label.TraefikBackendCircuitBreakerExpression, label.DefaultCircuitBreakerExpression),
|
||||||
"hasLoadBalancerLabels": hasLoadBalancerLabels,
|
// TODO Deprecated [breaking]
|
||||||
"getLoadBalancerMethod": getFuncString(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod),
|
"hasLoadBalancerLabels": hasLoadBalancerLabels,
|
||||||
"getSticky": getSticky,
|
// TODO Deprecated [breaking]
|
||||||
"hasStickinessLabel": hasFunc(label.TraefikBackendLoadBalancerStickiness),
|
"getLoadBalancerMethod": getFuncString(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod),
|
||||||
"getStickinessCookieName": getFuncString(label.TraefikBackendLoadBalancerStickinessCookieName, ""),
|
// TODO Deprecated [breaking]
|
||||||
"hasMaxConnLabels": hasMaxConnLabels,
|
"getSticky": getSticky,
|
||||||
"getMaxConnExtractorFunc": getFuncString(label.TraefikBackendMaxConnExtractorFunc, label.DefaultBackendMaxconnExtractorFunc),
|
// TODO Deprecated [breaking]
|
||||||
"getMaxConnAmount": getFuncInt64(label.TraefikBackendMaxConnAmount, math.MaxInt64),
|
"hasStickinessLabel": hasFunc(label.TraefikBackendLoadBalancerStickiness),
|
||||||
"hasHealthCheckLabels": hasFunc(label.TraefikBackendHealthCheckPath),
|
// TODO Deprecated [breaking]
|
||||||
"getHealthCheckPath": getFuncString(label.TraefikBackendHealthCheckPath, ""),
|
"getStickinessCookieName": getFuncString(label.TraefikBackendLoadBalancerStickinessCookieName, ""),
|
||||||
"getHealthCheckPort": getFuncInt(label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort),
|
// TODO Deprecated [breaking]
|
||||||
"getHealthCheckInterval": getFuncString(label.TraefikBackendHealthCheckInterval, ""),
|
"hasMaxConnLabels": hasMaxConnLabels,
|
||||||
|
// TODO Deprecated [breaking]
|
||||||
|
"getMaxConnExtractorFunc": getFuncString(label.TraefikBackendMaxConnExtractorFunc, label.DefaultBackendMaxconnExtractorFunc),
|
||||||
|
// TODO Deprecated [breaking]
|
||||||
|
"getMaxConnAmount": getFuncInt64(label.TraefikBackendMaxConnAmount, math.MaxInt64),
|
||||||
|
// TODO Deprecated [breaking]
|
||||||
|
"hasHealthCheckLabels": hasFunc(label.TraefikBackendHealthCheckPath),
|
||||||
|
// TODO Deprecated [breaking]
|
||||||
|
"getHealthCheckPath": getFuncString(label.TraefikBackendHealthCheckPath, ""),
|
||||||
|
// TODO Deprecated [breaking]
|
||||||
|
"getHealthCheckInterval": getFuncString(label.TraefikBackendHealthCheckInterval, ""),
|
||||||
|
|
||||||
// Frontend functions
|
// Frontend functions
|
||||||
"getPassHostHeader": getFuncStringService(label.SuffixFrontendPassHostHeader, label.DefaultPassHostHeader),
|
"getServiceNames": getServiceNames,
|
||||||
"getPassTLSCert": getFuncBoolService(label.SuffixFrontendPassTLSCert, label.DefaultPassTLSCert),
|
"getServiceNameSuffix": getServiceNameSuffix,
|
||||||
"getPriority": getFuncStringService(label.SuffixFrontendPriority, label.DefaultFrontendPriority),
|
"getPassHostHeader": getFuncBoolService(label.SuffixFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||||
"getEntryPoints": getFuncSliceStringService(label.SuffixFrontendEntryPoints),
|
"getPassTLSCert": getFuncBoolService(label.SuffixFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||||
"getFrontendRule": p.getFrontendRule,
|
"getPriority": getFuncIntService(label.SuffixFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||||
"getFrontendName": p.getFrontendName,
|
"getEntryPoints": getFuncSliceStringService(label.SuffixFrontendEntryPoints),
|
||||||
"getBasicAuth": getFuncSliceStringService(label.SuffixFrontendAuthBasic),
|
"getFrontendRule": p.getFrontendRule,
|
||||||
"getServiceNames": getServiceNames,
|
"getFrontendName": p.getFrontendName,
|
||||||
"getServiceNameSuffix": getServiceNameSuffix,
|
"getBasicAuth": getFuncSliceStringService(label.SuffixFrontendAuthBasic),
|
||||||
"getWhitelistSourceRange": getFuncSliceStringService(label.SuffixFrontendWhitelistSourceRange),
|
"getWhitelistSourceRange": getFuncSliceStringService(label.SuffixFrontendWhitelistSourceRange),
|
||||||
"hasRedirect": hasRedirect,
|
"getRedirect": getRedirect,
|
||||||
"getRedirectEntryPoint": getFuncStringService(label.SuffixFrontendRedirectEntryPoint, label.DefaultFrontendRedirectEntryPoint),
|
"getErrorPages": getErrorPages,
|
||||||
"getRedirectRegex": getFuncStringService(label.SuffixFrontendRedirectRegex, ""),
|
"getRateLimit": getRateLimit,
|
||||||
"getRedirectReplacement": getFuncStringService(label.SuffixFrontendRedirectReplacement, ""),
|
"getHeaders": getHeaders,
|
||||||
"hasErrorPages": hasPrefixFuncService(label.BaseFrontendErrorPage),
|
|
||||||
"getErrorPages": getErrorPages,
|
|
||||||
"hasRateLimits": hasFuncService(label.SuffixFrontendRateLimitExtractorFunc),
|
|
||||||
"getRateLimitsExtractorFunc": getFuncStringService(label.SuffixFrontendRateLimitExtractorFunc, ""),
|
|
||||||
"getRateLimits": getRateLimits,
|
|
||||||
// Headers
|
|
||||||
"hasHeaders": hasPrefixFuncService(label.TraefikFrontendHeaders),
|
|
||||||
"hasRequestHeaders": hasFuncService(label.SuffixFrontendRequestHeaders),
|
|
||||||
"getRequestHeaders": getFuncMapService(label.SuffixFrontendRequestHeaders),
|
|
||||||
"hasResponseHeaders": hasFuncService(label.SuffixFrontendResponseHeaders),
|
|
||||||
"getResponseHeaders": getFuncMapService(label.SuffixFrontendResponseHeaders),
|
|
||||||
"hasAllowedHostsHeaders": hasFuncService(label.SuffixFrontendHeadersAllowedHosts),
|
|
||||||
"getAllowedHostsHeaders": getFuncSliceStringService(label.SuffixFrontendHeadersAllowedHosts),
|
|
||||||
"hasHostsProxyHeaders": hasFuncService(label.SuffixFrontendHeadersHostsProxyHeaders),
|
|
||||||
"getHostsProxyHeaders": getFuncSliceStringService(label.SuffixFrontendHeadersHostsProxyHeaders),
|
|
||||||
"hasSSLRedirectHeaders": hasFuncService(label.SuffixFrontendHeadersSSLRedirect),
|
|
||||||
"getSSLRedirectHeaders": getFuncBoolService(label.SuffixFrontendHeadersSSLRedirect, false),
|
|
||||||
"hasSSLTemporaryRedirectHeaders": hasFuncService(label.SuffixFrontendHeadersSSLTemporaryRedirect),
|
|
||||||
"getSSLTemporaryRedirectHeaders": getFuncBoolService(label.SuffixFrontendHeadersSSLTemporaryRedirect, false),
|
|
||||||
"hasSSLHostHeaders": hasFuncService(label.SuffixFrontendHeadersSSLHost),
|
|
||||||
"getSSLHostHeaders": getFuncStringService(label.SuffixFrontendHeadersSSLHost, ""),
|
|
||||||
"hasSSLProxyHeaders": hasFuncService(label.SuffixFrontendHeadersSSLProxyHeaders),
|
|
||||||
"getSSLProxyHeaders": getFuncMapService(label.SuffixFrontendHeadersSSLProxyHeaders),
|
|
||||||
"hasSTSSecondsHeaders": hasFuncService(label.SuffixFrontendHeadersSTSSeconds),
|
|
||||||
"getSTSSecondsHeaders": getFuncInt64Service(label.SuffixFrontendHeadersSTSSeconds, 0),
|
|
||||||
"hasSTSIncludeSubdomainsHeaders": hasFuncService(label.SuffixFrontendHeadersSTSIncludeSubdomains),
|
|
||||||
"getSTSIncludeSubdomainsHeaders": getFuncBoolService(label.SuffixFrontendHeadersSTSIncludeSubdomains, false),
|
|
||||||
"hasSTSPreloadHeaders": hasFuncService(label.SuffixFrontendHeadersSTSPreload),
|
|
||||||
"getSTSPreloadHeaders": getFuncBoolService(label.SuffixFrontendHeadersSTSPreload, false),
|
|
||||||
"hasForceSTSHeaderHeaders": hasFuncService(label.SuffixFrontendHeadersForceSTSHeader),
|
|
||||||
"getForceSTSHeaderHeaders": getFuncBoolService(label.SuffixFrontendHeadersForceSTSHeader, false),
|
|
||||||
"hasFrameDenyHeaders": hasFuncService(label.SuffixFrontendHeadersFrameDeny),
|
|
||||||
"getFrameDenyHeaders": getFuncBoolService(label.SuffixFrontendHeadersFrameDeny, false),
|
|
||||||
"hasCustomFrameOptionsValueHeaders": hasFuncService(label.SuffixFrontendHeadersCustomFrameOptionsValue),
|
|
||||||
"getCustomFrameOptionsValueHeaders": getFuncStringService(label.SuffixFrontendHeadersCustomFrameOptionsValue, ""),
|
|
||||||
"hasContentTypeNosniffHeaders": hasFuncService(label.SuffixFrontendHeadersContentTypeNosniff),
|
|
||||||
"getContentTypeNosniffHeaders": getFuncBoolService(label.SuffixFrontendHeadersContentTypeNosniff, false),
|
|
||||||
"hasBrowserXSSFilterHeaders": hasFuncService(label.SuffixFrontendHeadersBrowserXSSFilter),
|
|
||||||
"getBrowserXSSFilterHeaders": getFuncBoolService(label.SuffixFrontendHeadersBrowserXSSFilter, false),
|
|
||||||
"hasContentSecurityPolicyHeaders": hasFuncService(label.SuffixFrontendHeadersContentSecurityPolicy),
|
|
||||||
"getContentSecurityPolicyHeaders": getFuncStringService(label.SuffixFrontendHeadersContentSecurityPolicy, ""),
|
|
||||||
"hasPublicKeyHeaders": hasFuncService(label.SuffixFrontendHeadersPublicKey),
|
|
||||||
"getPublicKeyHeaders": getFuncStringService(label.SuffixFrontendHeadersPublicKey, ""),
|
|
||||||
"hasReferrerPolicyHeaders": hasFuncService(label.SuffixFrontendHeadersReferrerPolicy),
|
|
||||||
"getReferrerPolicyHeaders": getFuncStringService(label.SuffixFrontendHeadersReferrerPolicy, ""),
|
|
||||||
"hasIsDevelopmentHeaders": hasFuncService(label.SuffixFrontendHeadersIsDevelopment),
|
|
||||||
"getIsDevelopmentHeaders": getFuncBoolService(label.SuffixFrontendHeadersIsDevelopment, false),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
@ -224,7 +199,7 @@ func (p *Provider) getBackend(application marathon.Application, serviceName stri
|
|||||||
lblBackend := getLabelName(serviceName, label.SuffixBackend)
|
lblBackend := getLabelName(serviceName, label.SuffixBackend)
|
||||||
value := label.GetStringValue(labels, lblBackend, "")
|
value := label.GetStringValue(labels, lblBackend, "")
|
||||||
if len(value) > 0 {
|
if len(value) > 0 {
|
||||||
return "backend" + value
|
return provider.Normalize("backend" + value)
|
||||||
}
|
}
|
||||||
return provider.Normalize("backend" + application.ID + getServiceNameSuffix(serviceName))
|
return provider.Normalize("backend" + application.ID + getServiceNameSuffix(serviceName))
|
||||||
}
|
}
|
||||||
@ -295,7 +270,7 @@ func getServiceNames(application marathon.Application) []string {
|
|||||||
// An empty name "" will be added if no service specific properties exist,
|
// An empty name "" will be added if no service specific properties exist,
|
||||||
// as an indication that there are no sub-services, but only main application
|
// as an indication that there are no sub-services, but only main application
|
||||||
if len(names) == 0 {
|
if len(names) == 0 {
|
||||||
names = append(names, "")
|
names = append(names, defaultService)
|
||||||
}
|
}
|
||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
@ -328,6 +303,7 @@ func logIllegalServices(task marathon.Task, application marathon.Application) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated
|
||||||
func hasLoadBalancerLabels(application marathon.Application) bool {
|
func hasLoadBalancerLabels(application marathon.Application) bool {
|
||||||
method := label.HasP(application.Labels, label.TraefikBackendLoadBalancerMethod)
|
method := label.HasP(application.Labels, label.TraefikBackendLoadBalancerMethod)
|
||||||
sticky := label.HasP(application.Labels, label.TraefikBackendLoadBalancerSticky)
|
sticky := label.HasP(application.Labels, label.TraefikBackendLoadBalancerSticky)
|
||||||
@ -335,6 +311,7 @@ func hasLoadBalancerLabels(application marathon.Application) bool {
|
|||||||
return method || sticky || stickiness
|
return method || sticky || stickiness
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated
|
||||||
func hasMaxConnLabels(application marathon.Application) bool {
|
func hasMaxConnLabels(application marathon.Application) bool {
|
||||||
mca := label.HasP(application.Labels, label.TraefikBackendMaxConnAmount)
|
mca := label.HasP(application.Labels, label.TraefikBackendMaxConnAmount)
|
||||||
mcef := label.HasP(application.Labels, label.TraefikBackendMaxConnExtractorFunc)
|
mcef := label.HasP(application.Labels, label.TraefikBackendMaxConnExtractorFunc)
|
||||||
@ -344,11 +321,11 @@ func hasMaxConnLabels(application marathon.Application) bool {
|
|||||||
// TODO: Deprecated
|
// TODO: Deprecated
|
||||||
// replaced by Stickiness
|
// replaced by Stickiness
|
||||||
// Deprecated
|
// Deprecated
|
||||||
func getSticky(application marathon.Application) string {
|
func getSticky(application marathon.Application) bool {
|
||||||
if label.HasP(application.Labels, label.TraefikBackendLoadBalancerSticky) {
|
if label.HasP(application.Labels, label.TraefikBackendLoadBalancerSticky) {
|
||||||
log.Warnf("Deprecated configuration found: %s. Please use %s.", label.TraefikBackendLoadBalancerSticky, label.TraefikBackendLoadBalancerStickiness)
|
log.Warnf("Deprecated configuration found: %s. Please use %s.", label.TraefikBackendLoadBalancerSticky, label.TraefikBackendLoadBalancerStickiness)
|
||||||
}
|
}
|
||||||
return label.GetStringValueP(application.Labels, label.TraefikBackendLoadBalancerSticky, "false")
|
return label.GetBoolValueP(application.Labels, label.TraefikBackendLoadBalancerSticky, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPort(task marathon.Task, application marathon.Application, serviceName string) string {
|
func getPort(task marathon.Task, application marathon.Application, serviceName string) string {
|
||||||
@ -420,14 +397,109 @@ func retrieveAvailablePorts(application marathon.Application, task marathon.Task
|
|||||||
return []int{}
|
return []int{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasRedirect(application marathon.Application, serviceName string) bool {
|
func getCircuitBreaker(application marathon.Application) *types.CircuitBreaker {
|
||||||
|
circuitBreaker := label.GetStringValueP(application.Labels, label.TraefikBackendCircuitBreakerExpression, "")
|
||||||
|
if len(circuitBreaker) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &types.CircuitBreaker{Expression: circuitBreaker}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLoadBalancer(application marathon.Application) *types.LoadBalancer {
|
||||||
|
if !label.HasPrefixP(application.Labels, label.TraefikBackendLoadBalancer) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
method := label.GetStringValueP(application.Labels, label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod)
|
||||||
|
|
||||||
|
lb := &types.LoadBalancer{
|
||||||
|
Method: method,
|
||||||
|
Sticky: getSticky(application),
|
||||||
|
}
|
||||||
|
|
||||||
|
if label.GetBoolValueP(application.Labels, label.TraefikBackendLoadBalancerStickiness, false) {
|
||||||
|
cookieName := label.GetStringValueP(application.Labels, label.TraefikBackendLoadBalancerStickinessCookieName, label.DefaultBackendLoadbalancerStickinessCookieName)
|
||||||
|
lb.Stickiness = &types.Stickiness{CookieName: cookieName}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lb
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMaxConn(application marathon.Application) *types.MaxConn {
|
||||||
|
amount := label.GetInt64ValueP(application.Labels, label.TraefikBackendMaxConnAmount, math.MinInt64)
|
||||||
|
extractorFunc := label.GetStringValueP(application.Labels, label.TraefikBackendMaxConnExtractorFunc, label.DefaultBackendMaxconnExtractorFunc)
|
||||||
|
|
||||||
|
if amount == math.MinInt64 || len(extractorFunc) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.MaxConn{
|
||||||
|
Amount: amount,
|
||||||
|
ExtractorFunc: extractorFunc,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getHealthCheck(application marathon.Application) *types.HealthCheck {
|
||||||
|
path := label.GetStringValueP(application.Labels, label.TraefikBackendHealthCheckPath, "")
|
||||||
|
if len(path) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
port := label.GetIntValueP(application.Labels, label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort)
|
||||||
|
interval := label.GetStringValueP(application.Labels, label.TraefikBackendHealthCheckInterval, "")
|
||||||
|
|
||||||
|
return &types.HealthCheck{
|
||||||
|
Path: path,
|
||||||
|
Port: port,
|
||||||
|
Interval: interval,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Provider) getServers(application marathon.Application, serviceName string) map[string]types.Server {
|
||||||
|
var servers map[string]types.Server
|
||||||
|
|
||||||
|
for _, task := range application.Tasks {
|
||||||
|
host := p.getBackendServer(*task, application)
|
||||||
|
if len(host) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if servers == nil {
|
||||||
|
servers = make(map[string]types.Server)
|
||||||
|
}
|
||||||
|
|
||||||
|
labels := getLabels(application, serviceName)
|
||||||
|
|
||||||
|
port := getPort(*task, application, serviceName)
|
||||||
|
protocol := label.GetStringValue(labels, getLabelName(serviceName, label.SuffixProtocol), label.DefaultProtocol)
|
||||||
|
|
||||||
|
serverName := provider.Normalize("server-" + task.ID + getServiceNameSuffix(serviceName))
|
||||||
|
servers[serverName] = types.Server{
|
||||||
|
URL: fmt.Sprintf("%s://%s:%v", protocol, host, port),
|
||||||
|
Weight: label.GetIntValue(labels, getLabelName(serviceName, label.SuffixWeight), label.DefaultWeightInt),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return servers
|
||||||
|
}
|
||||||
|
|
||||||
|
func getRedirect(application marathon.Application, serviceName string) *types.Redirect {
|
||||||
labels := getLabels(application, serviceName)
|
labels := getLabels(application, serviceName)
|
||||||
|
|
||||||
frep := label.Has(labels, getLabelName(serviceName, label.SuffixFrontendRedirectEntryPoint))
|
if label.Has(labels, getLabelName(serviceName, label.SuffixFrontendRedirectEntryPoint)) {
|
||||||
frrg := label.Has(labels, getLabelName(serviceName, label.SuffixFrontendRedirectRegex))
|
return &types.Redirect{
|
||||||
frrp := label.Has(labels, getLabelName(serviceName, label.SuffixFrontendRedirectReplacement))
|
EntryPoint: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendRedirectEntryPoint), ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if label.Has(labels, getLabelName(serviceName, label.SuffixFrontendRedirectRegex)) &&
|
||||||
|
label.Has(labels, getLabelName(serviceName, label.SuffixFrontendRedirectReplacement)) {
|
||||||
|
return &types.Redirect{
|
||||||
|
Regex: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendRedirectRegex), ""),
|
||||||
|
Replacement: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendRedirectReplacement), ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return frep || frrg && frrp
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getErrorPages(application marathon.Application, serviceName string) map[string]*types.ErrorPage {
|
func getErrorPages(application marathon.Application, serviceName string) map[string]*types.ErrorPage {
|
||||||
@ -440,14 +512,65 @@ func getErrorPages(application marathon.Application, serviceName string) map[str
|
|||||||
return label.ParseErrorPages(labels, prefix, label.RegexpFrontendErrorPage)
|
return label.ParseErrorPages(labels, prefix, label.RegexpFrontendErrorPage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRateLimits(application marathon.Application, serviceName string) map[string]*types.Rate {
|
func getRateLimit(application marathon.Application, serviceName string) *types.RateLimit {
|
||||||
labels := getLabels(application, serviceName)
|
labels := getLabels(application, serviceName)
|
||||||
prefix := getLabelName(serviceName, label.BaseFrontendRateLimit)
|
|
||||||
|
extractorFunc := label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendRateLimitExtractorFunc), "")
|
||||||
|
if len(extractorFunc) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
limits := getRateSet(labels, serviceName)
|
||||||
|
if len(limits) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.RateLimit{
|
||||||
|
ExtractorFunc: extractorFunc,
|
||||||
|
RateSet: limits,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getRateSet(labels map[string]string, serviceName string) map[string]*types.Rate {
|
||||||
|
rateSetPrefix := getLabelName(serviceName, label.BaseFrontendRateLimit)
|
||||||
|
|
||||||
if len(serviceName) > 0 {
|
if len(serviceName) > 0 {
|
||||||
return label.ParseRateSets(labels, prefix, label.RegexpBaseFrontendRateLimit)
|
return label.ParseRateSets(labels, rateSetPrefix, label.RegexpBaseFrontendRateLimit)
|
||||||
}
|
}
|
||||||
return label.ParseRateSets(labels, prefix, label.RegexpFrontendRateLimit)
|
return label.ParseRateSets(labels, rateSetPrefix, label.RegexpFrontendRateLimit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getHeaders(application marathon.Application, serviceName string) *types.Headers {
|
||||||
|
labels := getLabels(application, serviceName)
|
||||||
|
|
||||||
|
headers := &types.Headers{
|
||||||
|
CustomRequestHeaders: label.GetMapValue(labels, getLabelName(serviceName, label.SuffixFrontendRequestHeaders)),
|
||||||
|
CustomResponseHeaders: label.GetMapValue(labels, getLabelName(serviceName, label.SuffixFrontendResponseHeaders)),
|
||||||
|
SSLProxyHeaders: label.GetMapValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersSSLProxyHeaders)),
|
||||||
|
AllowedHosts: label.GetSliceStringValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersAllowedHosts)),
|
||||||
|
HostsProxyHeaders: label.GetSliceStringValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersHostsProxyHeaders)),
|
||||||
|
STSSeconds: label.GetInt64Value(labels, getLabelName(serviceName, label.SuffixFrontendHeadersSTSSeconds), 0),
|
||||||
|
SSLRedirect: label.GetBoolValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersSSLRedirect), false),
|
||||||
|
SSLTemporaryRedirect: label.GetBoolValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersSSLTemporaryRedirect), false),
|
||||||
|
STSIncludeSubdomains: label.GetBoolValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersSTSIncludeSubdomains), false),
|
||||||
|
STSPreload: label.GetBoolValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersSTSPreload), false),
|
||||||
|
ForceSTSHeader: label.GetBoolValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersForceSTSHeader), false),
|
||||||
|
FrameDeny: label.GetBoolValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersFrameDeny), false),
|
||||||
|
ContentTypeNosniff: label.GetBoolValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersContentTypeNosniff), false),
|
||||||
|
BrowserXSSFilter: label.GetBoolValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersBrowserXSSFilter), false),
|
||||||
|
IsDevelopment: label.GetBoolValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersIsDevelopment), false),
|
||||||
|
SSLHost: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersSSLHost), ""),
|
||||||
|
CustomFrameOptionsValue: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersCustomFrameOptionsValue), ""),
|
||||||
|
ContentSecurityPolicy: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersContentSecurityPolicy), ""),
|
||||||
|
PublicKey: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersPublicKey), ""),
|
||||||
|
ReferrerPolicy: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendHeadersReferrerPolicy), ""),
|
||||||
|
}
|
||||||
|
|
||||||
|
if !headers.HasSecureHeadersDefined() && !headers.HasCustomHeadersDefined() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return headers
|
||||||
}
|
}
|
||||||
|
|
||||||
// Label functions
|
// Label functions
|
||||||
@ -477,25 +600,6 @@ func hasFunc(labelName string) func(application marathon.Application) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasFuncService(labelName string) func(application marathon.Application, serviceName string) bool {
|
|
||||||
return func(application marathon.Application, serviceName string) bool {
|
|
||||||
labels := getLabels(application, serviceName)
|
|
||||||
lbName := getLabelName(serviceName, labelName)
|
|
||||||
|
|
||||||
value, ok := labels[lbName]
|
|
||||||
return ok && len(value) > 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func hasPrefixFuncService(prefix string) func(application marathon.Application, serviceName string) bool {
|
|
||||||
return func(application marathon.Application, serviceName string) bool {
|
|
||||||
labels := getLabels(application, serviceName)
|
|
||||||
lbName := getLabelName(serviceName, prefix)
|
|
||||||
|
|
||||||
return label.HasPrefix(labels, lbName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getFuncStringService(labelName string, defaultValue string) func(application marathon.Application, serviceName string) string {
|
func getFuncStringService(labelName string, defaultValue string) func(application marathon.Application, serviceName string) string {
|
||||||
return func(application marathon.Application, serviceName string) string {
|
return func(application marathon.Application, serviceName string) string {
|
||||||
labels := getLabels(application, serviceName)
|
labels := getLabels(application, serviceName)
|
||||||
@ -512,11 +616,11 @@ func getFuncBoolService(labelName string, defaultValue bool) func(application ma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFuncInt64Service(labelName string, defaultValue int64) func(application marathon.Application, serviceName string) int64 {
|
func getFuncIntService(labelName string, defaultValue int) func(application marathon.Application, serviceName string) int {
|
||||||
return func(application marathon.Application, serviceName string) int64 {
|
return func(application marathon.Application, serviceName string) int {
|
||||||
labels := getLabels(application, serviceName)
|
labels := getLabels(application, serviceName)
|
||||||
lbName := getLabelName(serviceName, labelName)
|
lbName := getLabelName(serviceName, labelName)
|
||||||
return label.GetInt64Value(labels, lbName, defaultValue)
|
return label.GetIntValue(labels, lbName, defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,13 +631,6 @@ func getFuncSliceStringService(labelName string) func(application marathon.Appli
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFuncMapService(labelName string) func(application marathon.Application, serviceName string) map[string]string {
|
|
||||||
return func(application marathon.Application, serviceName string) map[string]string {
|
|
||||||
labels := getLabels(application, serviceName)
|
|
||||||
return label.GetMapValue(labels, getLabelName(serviceName, labelName))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getFuncString(labelName string, defaultValue string) func(application marathon.Application) string {
|
func getFuncString(labelName string, defaultValue string) func(application marathon.Application) string {
|
||||||
return func(application marathon.Application) string {
|
return func(application marathon.Application) string {
|
||||||
return label.GetStringValueP(application.Labels, labelName, defaultValue)
|
return label.GetStringValueP(application.Labels, labelName, defaultValue)
|
||||||
@ -545,9 +642,3 @@ func getFuncInt64(labelName string, defaultValue int64) func(application maratho
|
|||||||
return label.GetInt64ValueP(application.Labels, labelName, defaultValue)
|
return label.GetInt64ValueP(application.Labels, labelName, defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFuncInt(labelName string, defaultValue int) func(application marathon.Application) int {
|
|
||||||
return func(application marathon.Application) int {
|
|
||||||
return label.GetIntValueP(application.Labels, labelName, defaultValue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,192 +1,168 @@
|
|||||||
{{$apps := .Applications}}
|
{{ $apps := .Applications }}
|
||||||
|
|
||||||
[backends]
|
[backends]
|
||||||
{{range $app := $apps}}
|
{{range $app := $apps }}
|
||||||
{{range $serviceIndex, $serviceName := getServiceNames $app}}
|
{{range $serviceIndex, $serviceName := getServiceNames $app }}
|
||||||
|
{{ $backendName := getBackend $app $serviceName}}
|
||||||
|
|
||||||
[backends."{{getBackend $app $serviceName }}"]
|
[backends."{{ $backendName }}"]
|
||||||
|
|
||||||
{{ if hasCircuitBreakerLabels $app }}
|
{{ $circuitBreaker := getCircuitBreaker $app }}
|
||||||
[backends."{{getBackend $app $serviceName }}".circuitBreaker]
|
{{if $circuitBreaker }}
|
||||||
expression = "{{getCircuitBreakerExpression $app }}"
|
[backends."{{ $backendName }}".circuitBreaker]
|
||||||
|
expression = "{{ $circuitBreaker.Expression }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ if hasLoadBalancerLabels $app }}
|
{{ $loadBalancer := getLoadBalancer $app }}
|
||||||
[backends."{{getBackend $app $serviceName }}".loadBalancer]
|
{{if $loadBalancer }}
|
||||||
method = "{{getLoadBalancerMethod $app }}"
|
[backends."{{ $backendName }}".loadBalancer]
|
||||||
sticky = {{getSticky $app}}
|
method = "{{ $loadBalancer.Method }}"
|
||||||
{{if hasStickinessLabel $app}}
|
sticky = {{ $loadBalancer.Sticky }}
|
||||||
[backends."{{getBackend $app $serviceName }}".loadBalancer.stickiness]
|
{{if $loadBalancer.Stickiness }}
|
||||||
cookieName = "{{getStickinessCookieName $app}}"
|
[backends."{{ $backendName }}".loadBalancer.stickiness]
|
||||||
|
cookieName = "{{ $loadBalancer.Stickiness.CookieName }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ if hasMaxConnLabels $app }}
|
{{ $maxConn := getMaxConn $app }}
|
||||||
[backends."{{getBackend $app $serviceName }}".maxConn]
|
{{if $maxConn }}
|
||||||
amount = {{getMaxConnAmount $app }}
|
[backends."{{ $backendName }}".maxConn]
|
||||||
extractorFunc = "{{getMaxConnExtractorFunc $app }}"
|
extractorFunc = "{{ $maxConn.ExtractorFunc }}"
|
||||||
|
amount = {{ $maxConn.Amount }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ if hasHealthCheckLabels $app }}
|
{{ $healthCheck := getHealthCheck $app }}
|
||||||
[backends."{{getBackend $app $serviceName }}".healthCheck]
|
{{if $healthCheck }}
|
||||||
path = "{{getHealthCheckPath $app }}"
|
[backends."{{ $backendName }}".healthCheck]
|
||||||
port = {{getHealthCheckPort $app}}
|
path = "{{ $healthCheck.Path }}"
|
||||||
interval = "{{getHealthCheckInterval $app }}"
|
port = {{ $healthCheck.Port }}
|
||||||
|
interval = "{{ $healthCheck.Interval }}"
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{range $serverName, $server := getServers $app $serviceName }}
|
||||||
|
[backends."{{ $backendName }}".servers."{{ $serverName }}"]
|
||||||
|
url = "{{ $server.URL }}"
|
||||||
|
weight = {{ $server.Weight }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{range $task := $app.Tasks}}
|
|
||||||
{{range $serviceIndex, $serviceName := getServiceNames $app}}
|
|
||||||
|
|
||||||
[backends."{{getBackend $app $serviceName}}".servers."server-{{$task.ID | replace "." "-"}}{{getServiceNameSuffix $serviceName }}"]
|
|
||||||
url = "{{getProtocol $app $serviceName}}://{{getBackendServer $task $app}}:{{getPort $task $app $serviceName}}"
|
|
||||||
weight = {{getWeight $app $serviceName}}
|
|
||||||
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
[frontends]
|
[frontends]
|
||||||
{{range $app := $apps}}
|
{{range $app := $apps }}
|
||||||
{{range $serviceIndex, $serviceName := getServiceNames .}}
|
{{range $serviceIndex, $serviceName := getServiceNames $app }}
|
||||||
|
{{ $frontendName := getFrontendName $app $serviceName }}
|
||||||
|
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}"]
|
[frontends."{{ $frontendName }}"]
|
||||||
backend = "{{getBackend $app $serviceName}}"
|
backend = "{{ getBackend $app $serviceName }}"
|
||||||
priority = {{getPriority $app $serviceName}}
|
priority = {{ getPriority $app $serviceName }}
|
||||||
passHostHeader = {{getPassHostHeader $app $serviceName}}
|
passHostHeader = {{ getPassHostHeader $app $serviceName }}
|
||||||
passTLSCert = {{getPassTLSCert $app $serviceName}}
|
passTLSCert = {{ getPassTLSCert $app $serviceName }}
|
||||||
|
|
||||||
entryPoints = [{{range getEntryPoints $app $serviceName}}
|
entryPoints = [{{range getEntryPoints $app $serviceName }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
|
|
||||||
{{if getWhitelistSourceRange $app $serviceName}}
|
{{ $whitelistSourceRange := getWhitelistSourceRange $app $serviceName }}
|
||||||
whitelistSourceRange = [{{range getWhitelistSourceRange $app $serviceName}}
|
{{if $whitelistSourceRange }}
|
||||||
|
whitelistSourceRange = [{{range $whitelistSourceRange }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
basicAuth = [{{range getBasicAuth $app $serviceName}}
|
basicAuth = [{{range getBasicAuth $app $serviceName }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
|
|
||||||
{{if hasRedirect $app $serviceName}}
|
{{ $redirect := getRedirect $app $serviceName }}
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".redirect]
|
{{if $redirect }}
|
||||||
entryPoint = "{{getRedirectEntryPoint $app $serviceName}}"
|
[frontends."{{ $frontendName }}".redirect]
|
||||||
regex = "{{getRedirectRegex $app $serviceName}}"
|
entryPoint = "{{ $redirect.EntryPoint }}"
|
||||||
replacement = "{{getRedirectReplacement $app $serviceName}}"
|
regex = "{{ $redirect.Regex }}"
|
||||||
|
replacement = "{{ $redirect.Replacement }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ if hasErrorPages $app $serviceName }}
|
{{ $errorPages := getErrorPages $app $serviceName }}
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".errors]
|
{{if $errorPages }}
|
||||||
{{ range $pageName, $page := getErrorPages $app $serviceName }}
|
[frontends."{{ $frontendName }}".errors]
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".errors.{{ $pageName }}]
|
{{range $pageName, $page := $errorPages }}
|
||||||
status = [{{range $page.Status}}
|
[frontends."{{ $frontendName }}".errors.{{ $pageName }}]
|
||||||
"{{.}}",
|
status = [{{range $page.Status }}
|
||||||
{{end}}]
|
"{{.}}",
|
||||||
backend = "{{$page.Backend}}"
|
{{end}}]
|
||||||
query = "{{$page.Query}}"
|
backend = "{{ $page.Backend }}"
|
||||||
|
query = "{{ $page.Query }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{ if hasRateLimits $app $serviceName }}
|
{{ $rateLimit := getRateLimit $app $serviceName }}
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".rateLimit]
|
{{if $rateLimit }}
|
||||||
extractorFunc = "{{ getRateLimitsExtractorFunc $app $serviceName }}"
|
[frontends."{{ $frontendName }}".rateLimit]
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".rateLimit.rateSet]
|
extractorFunc = "{{ $rateLimit.ExtractorFunc }}"
|
||||||
{{ range $limitName, $rateLimit := getRateLimits $app $serviceName }}
|
[frontends."{{ $frontendName }}".rateLimit.rateSet]
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".rateLimit.rateSet.{{ $limitName }}]
|
{{ range $limitName, $limit := $rateLimit.RateSet }}
|
||||||
period = "{{ $rateLimit.Period }}"
|
[frontends."{{ $frontendName }}".rateLimit.rateSet.{{ $limitName }}]
|
||||||
average = {{ $rateLimit.Average }}
|
period = "{{ $limit.Period }}"
|
||||||
burst = {{ $rateLimit.Burst }}
|
average = {{ $limit.Average }}
|
||||||
|
burst = {{ $limit.Burst }}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasHeaders $app $serviceName }}
|
{{ $headers := getHeaders $app $serviceName }}
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".headers]
|
{{if $headers }}
|
||||||
{{if hasSSLRedirectHeaders $app $serviceName}}
|
[frontends."{{ $frontendName }}".headers]
|
||||||
SSLRedirect = {{getSSLRedirectHeaders $app $serviceName}}
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
{{end}}
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
{{if hasSSLTemporaryRedirectHeaders $app $serviceName}}
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
SSLTemporaryRedirect = {{getSSLTemporaryRedirectHeaders $app $serviceName}}
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
{{end}}
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
{{if hasSSLHostHeaders $app $serviceName}}
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
SSLHost = "{{getSSLHostHeaders $app $serviceName}}"
|
ForceSTSHeader = {{ $headers.ForceSTSHeader }}
|
||||||
{{end}}
|
FrameDeny = {{ $headers.FrameDeny }}
|
||||||
{{if hasSTSSecondsHeaders $app $serviceName}}
|
CustomFrameOptionsValue = "{{ $headers.CustomFrameOptionsValue }}"
|
||||||
STSSeconds = {{getSTSSecondsHeaders $app $serviceName}}
|
ContentTypeNosniff = {{ $headers.ContentTypeNosniff }}
|
||||||
{{end}}
|
BrowserXSSFilter = {{ $headers.BrowserXSSFilter }}
|
||||||
{{if hasSTSIncludeSubdomainsHeaders $app $serviceName}}
|
ContentSecurityPolicy = "{{ $headers.ContentSecurityPolicy }}"
|
||||||
STSIncludeSubdomains = {{getSTSIncludeSubdomainsHeaders $app $serviceName}}
|
PublicKey = "{{ $headers.PublicKey }}"
|
||||||
{{end}}
|
ReferrerPolicy = "{{ $headers.ReferrerPolicy }}"
|
||||||
{{if hasSTSPreloadHeaders $app $serviceName}}
|
IsDevelopment = {{ $headers.IsDevelopment }}
|
||||||
STSPreload = {{getSTSPreloadHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
{{if hasForceSTSHeaderHeaders $app $serviceName}}
|
|
||||||
ForceSTSHeader = {{getForceSTSHeaderHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
{{if hasFrameDenyHeaders $app $serviceName}}
|
|
||||||
FrameDeny = {{getFrameDenyHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
{{if hasCustomFrameOptionsValueHeaders $app $serviceName}}
|
|
||||||
CustomFrameOptionsValue = "{{getCustomFrameOptionsValueHeaders $app $serviceName}}"
|
|
||||||
{{end}}
|
|
||||||
{{if hasContentTypeNosniffHeaders $app $serviceName}}
|
|
||||||
ContentTypeNosniff = {{getContentTypeNosniffHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
{{if hasBrowserXSSFilterHeaders $app $serviceName}}
|
|
||||||
BrowserXSSFilter = {{getBrowserXSSFilterHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
{{if hasContentSecurityPolicyHeaders $app $serviceName}}
|
|
||||||
ContentSecurityPolicy = "{{getContentSecurityPolicyHeaders $app $serviceName}}"
|
|
||||||
{{end}}
|
|
||||||
{{if hasPublicKeyHeaders $app $serviceName}}
|
|
||||||
PublicKey = "{{getPublicKeyHeaders $app $serviceName}}"
|
|
||||||
{{end}}
|
|
||||||
{{if hasReferrerPolicyHeaders $app $serviceName}}
|
|
||||||
ReferrerPolicy = "{{getReferrerPolicyHeaders $app $serviceName}}"
|
|
||||||
{{end}}
|
|
||||||
{{if hasIsDevelopmentHeaders $app $serviceName}}
|
|
||||||
IsDevelopment = {{getIsDevelopmentHeaders $app $serviceName}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{if hasAllowedHostsHeaders $app $serviceName}}
|
{{if $headers.AllowedHosts }}
|
||||||
AllowedHosts = [{{range getAllowedHostsHeaders $app $serviceName}}
|
AllowedHosts = [{{range $headers.AllowedHosts }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasHostsProxyHeaders $app $serviceName}}
|
{{if $headers.HostsProxyHeaders }}
|
||||||
HostsProxyHeaders = [{{range getHostsProxyHeaders $app $serviceName}}
|
HostsProxyHeaders = [{{range $headers.HostsProxyHeaders }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasRequestHeaders $app $serviceName}}
|
{{if $headers.CustomRequestHeaders }}
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".headers.customRequestHeaders]
|
[frontends."{{ $frontendName }}".headers.customRequestHeaders]
|
||||||
{{range $k, $v := getRequestHeaders $app $serviceName}}
|
{{range $k, $v := $headers.CustomRequestHeaders }}
|
||||||
{{$k}} = "{{$v}}"
|
{{$k}} = "{{$v}}"
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if $headers.CustomResponseHeaders }}
|
||||||
|
[frontends."{{ $frontendName }}".headers.customResponseHeaders]
|
||||||
|
{{range $k, $v := $headers.CustomResponseHeaders }}
|
||||||
|
{{$k}} = "{{$v}}"
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if $headers.SSLProxyHeaders }}
|
||||||
|
[frontends."{{ $frontendName }}".headers.SSLProxyHeaders]
|
||||||
|
{{range $k, $v := $headers.SSLProxyHeaders }}
|
||||||
|
{{$k}} = "{{$v}}"
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasResponseHeaders $app $serviceName}}
|
[frontends."{{ $frontendName }}".routes."route-host{{ $app.ID | replace "/" "-" }}{{ getServiceNameSuffix $serviceName }}"]
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".headers.customResponseHeaders]
|
rule = "{{ getFrontendRule $app $serviceName }}"
|
||||||
{{range $k, $v := getResponseHeaders $app $serviceName}}
|
|
||||||
{{$k}} = "{{$v}}"
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{if hasSSLProxyHeaders $app $serviceName}}
|
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".headers.SSLProxyHeaders]
|
|
||||||
{{range $k, $v := getSSLProxyHeaders $app $serviceName}}
|
|
||||||
{{$k}} = "{{$v}}"
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
[frontends."{{ getFrontendName $app $serviceName }}".routes."route-host{{$app.ID | replace "/" "-"}}{{getServiceNameSuffix $serviceName }}"]
|
|
||||||
rule = "{{getFrontendRule $app $serviceName}}"
|
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
Reference in New Issue
Block a user