homogenization of templates: ECS

This commit is contained in:
Ludovic Fernandez 2018-01-10 18:28:03 +01:00 committed by Traefiker
parent 0d57e2aed9
commit ee71b4bfef
4 changed files with 1300 additions and 425 deletions

View file

@ -543,173 +543,157 @@ func templatesDockerTmpl() (*asset, error) {
}
var _templatesEcsTmpl = []byte(`[backends]
{{range $serviceName, $instances := .Services}}
{{range $serviceName, $instances := .Services }}
{{ $firstInstance := index $instances 0 }}
{{if hasCircuitBreakerLabel $instances}}
[backends.backend-{{ $serviceName }}.circuitBreaker]
expression = "{{getCircuitBreakerExpression $instances}}"
{{ $circuitBreaker := getCircuitBreaker $firstInstance }}
{{if $circuitBreaker }}
[backends."backend-{{ $serviceName }}".circuitBreaker]
expression = "{{ $circuitBreaker.Expression }}"
{{end}}
{{if hasLoadBalancerLabel $instances}}
[backends.backend-{{ $serviceName }}.loadBalancer]
method = "{{ getLoadBalancerMethod $instances}}"
sticky = {{ getSticky $instances}}
{{if hasStickinessLabel $instances}}
[backends.backend-{{ $serviceName }}.loadBalancer.stickiness]
cookieName = "{{getStickinessCookieName $instances}}"
{{ $loadBalancer := getLoadBalancer $firstInstance }}
{{if $loadBalancer }}
[backends."backend-{{ $serviceName }}".loadBalancer]
method = "{{ $loadBalancer.Method }}"
sticky = {{ $loadBalancer.Sticky }}
{{if $loadBalancer.Stickiness }}
[backends."backend-{{ $serviceName }}".loadBalancer.stickiness]
cookieName = "{{ $loadBalancer.Stickiness.CookieName }}"
{{end}}
{{end}}
{{if hasMaxConnLabels $instances}}
[backends.backend-{{ $serviceName }}.maxConn]
amount = {{getMaxConnAmount $instances}}
extractorFunc = "{{getMaxConnExtractorFunc $instances}}"
{{ $maxConn := getMaxConn $firstInstance }}
{{if $maxConn }}
[backends."backend-{{ $serviceName }}".maxConn]
extractorFunc = "{{ $maxConn.ExtractorFunc }}"
amount = {{ $maxConn.Amount }}
{{end}}
{{ if hasHealthCheckLabels $instances }}
{{ $healthCheck := getHealthCheck $firstInstance }}
{{if $healthCheck }}
[backends.backend-{{ $serviceName }}.healthCheck]
path = "{{getHealthCheckPath $instances }}"
port = {{getHealthCheckPort $instances}}
interval = "{{getHealthCheckInterval $instances }}"
path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}"
{{end}}
{{range $index, $instance := $instances}}
[backends.backend-{{ $instance.Name }}.servers.server-{{ $instance.Name }}{{ $instance.ID }}]
url = "{{ getProtocol $instance }}://{{ getHost $instance }}:{{ getPort $instance }}"
weight = {{ getWeight $instance}}
{{range $serverName, $server := getServers $instances }}
[backends.backend-{{ $serviceName }}.servers.{{ $serverName }}]
url = "{{ $server.URL }}"
weight = {{ $server.Weight }}
{{end}}
{{end}}
[frontends]
{{range $serviceName, $instances := .Services}}
{{range $instance := filterFrontends $instances}}
{{range $serviceName, $instances := .Services }}
{{range $instance := filterFrontends $instances }}
[frontends.frontend-{{ $serviceName }}]
backend = "backend-{{ $serviceName }}"
priority = {{ getPriority $instance}}
passHostHeader = {{ getPassHostHeader $instance}}
passTLSCert = {{ getPassTLSCert $instance}}
priority = {{ getPriority $instance }}
passHostHeader = {{ getPassHostHeader $instance }}
passTLSCert = {{ getPassTLSCert $instance }}
entryPoints = [{{range getEntryPoints $instance}}
entryPoints = [{{range getEntryPoints $instance }}
"{{.}}",
{{end}}]
{{if getWhitelistSourceRange $instance}}
whitelistSourceRange = [{{range getWhitelistSourceRange $instance}}
{{ $whitelistSourceRange := getWhitelistSourceRange $instance }}
{{if $whitelistSourceRange }}
whitelistSourceRange = [{{range $whitelistSourceRange }}
"{{.}}",
{{end}}]
{{end}}
basicAuth = [{{range getBasicAuth $instance}}
basicAuth = [{{range getBasicAuth $instance }}
"{{.}}",
{{end}}]
{{if hasRedirect $instance}}
{{ $redirect := getRedirect $instance }}
{{if $redirect }}
[frontends."frontend-{{ $serviceName }}".redirect]
entryPoint = "{{getRedirectEntryPoint $instance}}"
regex = "{{getRedirectRegex $instance}}"
replacement = "{{getRedirectReplacement $instance}}"
entryPoint = "{{ $redirect.EntryPoint }}"
regex = "{{ $redirect.Regex }}"
replacement = "{{ $redirect.Replacement }}"
{{end}}
{{ if hasErrorPages $instance }}
{{ $errorPages := getErrorPages $instance }}
{{if $errorPages }}
[frontends."frontend-{{ $serviceName }}".errors]
{{ range $pageName, $page := getErrorPages $instance }}
{{range $pageName, $page := $errorPages }}
[frontends."frontend-{{ $serviceName }}".errors.{{ $pageName }}]
status = [{{range $page.Status}}
status = [{{range $page.Status }}
"{{.}}",
{{end}}]
backend = "{{$page.Backend}}"
query = "{{$page.Query}}"
backend = "{{ $page.Backend }}"
query = "{{ $page.Query }}"
{{end}}
{{end}}
{{ if hasRateLimits $instance }}
{{ $rateLimit := getRateLimit $instance }}
{{if $rateLimit }}
[frontends."frontend-{{ $serviceName }}".rateLimit]
extractorFunc = "{{ getRateLimitsExtractorFunc $instance }}"
extractorFunc = "{{ $rateLimit.ExtractorFunc }}"
[frontends."frontend-{{ $serviceName }}".rateLimit.rateSet]
{{ range $limitName, $rateLimit := getRateLimits $instance }}
{{ range $limitName, $limit := $rateLimit.RateSet }}
[frontends."frontend-{{ $serviceName }}".rateLimit.rateSet.{{ $limitName }}]
period = "{{ $rateLimit.Period }}"
average = {{ $rateLimit.Average }}
burst = {{ $rateLimit.Burst }}
period = "{{ $limit.Period }}"
average = {{ $limit.Average }}
burst = {{ $limit.Burst }}
{{end}}
{{end}}
{{if hasHeaders $instance }}
{{ $headers := getHeaders $instance }}
{{if $headers }}
[frontends."frontend-{{ $serviceName }}".headers]
{{if hasSSLRedirectHeaders $instance}}
SSLRedirect = {{getSSLRedirectHeaders $instance}}
SSLRedirect = {{ $headers.SSLRedirect }}
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
SSLHost = "{{ $headers.SSLHost }}"
STSSeconds = {{ $headers.STSSeconds }}
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
STSPreload = {{ $headers.STSPreload }}
ForceSTSHeader = {{ $headers.ForceSTSHeader }}
FrameDeny = {{ $headers.FrameDeny }}
CustomFrameOptionsValue = "{{ $headers.CustomFrameOptionsValue }}"
ContentTypeNosniff = {{ $headers.ContentTypeNosniff }}
BrowserXSSFilter = {{ $headers.BrowserXSSFilter }}
ContentSecurityPolicy = "{{ $headers.ContentSecurityPolicy }}"
PublicKey = "{{ $headers.PublicKey }}"
ReferrerPolicy = "{{ $headers.ReferrerPolicy }}"
IsDevelopment = {{ $headers.IsDevelopment }}
{{if $headers.AllowedHosts }}
AllowedHosts = [{{range $headers.AllowedHosts }}
"{{.}}",
{{end}}]
{{end}}
{{if hasSSLTemporaryRedirectHeaders $instance}}
SSLTemporaryRedirect = {{getSSLTemporaryRedirectHeaders $instance}}
{{if $headers.HostsProxyHeaders }}
HostsProxyHeaders = [{{range $headers.HostsProxyHeaders }}
"{{.}}",
{{end}}]
{{end}}
{{if hasSSLHostHeaders $instance}}
SSLHost = "{{getSSLHostHeaders $instance}}"
{{end}}
{{if hasSTSSecondsHeaders $instance}}
STSSeconds = {{getSTSSecondsHeaders $instance}}
{{end}}
{{if hasSTSIncludeSubdomainsHeaders $instance}}
STSIncludeSubdomains = {{getSTSIncludeSubdomainsHeaders $instance}}
{{end}}
{{if hasSTSPreloadHeaders $instance}}
STSPreload = {{getSTSPreloadHeaders $instance}}
{{end}}
{{if hasForceSTSHeaderHeaders $instance}}
ForceSTSHeader = {{getForceSTSHeaderHeaders $instance}}
{{end}}
{{if hasFrameDenyHeaders $instance}}
FrameDeny = {{getFrameDenyHeaders $instance}}
{{end}}
{{if hasCustomFrameOptionsValueHeaders $instance}}
CustomFrameOptionsValue = "{{getCustomFrameOptionsValueHeaders $instance}}"
{{end}}
{{if hasContentTypeNosniffHeaders $instance}}
ContentTypeNosniff = {{getContentTypeNosniffHeaders $instance}}
{{end}}
{{if hasBrowserXSSFilterHeaders $instance}}
BrowserXSSFilter = {{getBrowserXSSFilterHeaders $instance}}
{{end}}
{{if hasContentSecurityPolicyHeaders $instance}}
ContentSecurityPolicy = "{{getContentSecurityPolicyHeaders $instance}}"
{{end}}
{{if hasPublicKeyHeaders $instance}}
PublicKey = "{{getPublicKeyHeaders $instance}}"
{{end}}
{{if hasReferrerPolicyHeaders $instance}}
ReferrerPolicy = "{{getReferrerPolicyHeaders $instance}}"
{{end}}
{{if hasIsDevelopmentHeaders $instance}}
IsDevelopment = {{getIsDevelopmentHeaders $instance}}
{{end}}
{{if hasRequestHeaders $instance}}
[frontends."frontend-{{ $serviceName }}".headers.customRequestHeaders]
{{range $k, $v := getRequestHeaders $instance}}
{{if $headers.CustomRequestHeaders }}
[frontends."frontend-{{ $serviceName }}".headers.customRequestHeaders]
{{range $k, $v := $headers.CustomRequestHeaders }}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
{{if hasResponseHeaders $instance}}
{{if $headers.CustomResponseHeaders }}
[frontends."frontend-{{ $serviceName }}".headers.customResponseHeaders]
{{range $k, $v := getResponseHeaders $instance}}
{{range $k, $v := $headers.CustomResponseHeaders }}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
{{if hasAllowedHostsHeaders $instance}}
[frontends."frontend-{{ $serviceName }}".headers.AllowedHosts]
{{range getAllowedHostsHeaders $instance}}
"{{.}}"
{{end}}
{{end}}
{{if hasHostsProxyHeaders $instance}}
[frontends."frontend-{{ $serviceName }}".headers.HostsProxyHeaders]
{{range getHostsProxyHeaders $instance}}
"{{.}}"
{{end}}
{{end}}
{{if hasSSLProxyHeaders $instance}}
{{if $headers.SSLProxyHeaders }}
[frontends."frontend-{{ $serviceName }}".headers.SSLProxyHeaders]
{{range $k, $v := getSSLProxyHeaders $instance}}
{{range $k, $v := $headers.SSLProxyHeaders }}
{{$k}} = "{{$v}}"
{{end}}
{{end}}

View file

@ -1,13 +1,16 @@
package ecs
import (
"fmt"
"math"
"strconv"
"strings"
"text/template"
"github.com/BurntSushi/ty/fun"
"github.com/aws/aws-sdk-go/aws"
"github.com/containous/traefik/log"
"github.com/containous/traefik/provider"
"github.com/containous/traefik/provider/label"
"github.com/containous/traefik/types"
)
@ -16,90 +19,51 @@ import (
func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types.Configuration, error) {
var ecsFuncMap = template.FuncMap{
// Backend functions
"getProtocol": getFuncStringValue(label.TraefikProtocol, label.DefaultProtocol),
"getHost": getHost,
"getPort": getPort,
"getWeight": getFuncStringValue(label.TraefikWeight, label.DefaultWeight),
"hasLoadBalancerLabel": hasLoadBalancerLabel,
"getLoadBalancerMethod": getFuncFirstStringValue(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod),
"getSticky": getSticky,
"hasStickinessLabel": getFuncFirstBoolValue(label.TraefikBackendLoadBalancerStickiness, false),
"getStickinessCookieName": getFuncFirstStringValue(label.TraefikBackendLoadBalancerStickinessCookieName, label.DefaultBackendLoadbalancerStickinessCookieName),
"hasHealthCheckLabels": hasFuncFirst(label.TraefikBackendHealthCheckPath),
"getHealthCheckPath": getFuncFirstStringValue(label.TraefikBackendHealthCheckPath, ""),
"getHealthCheckPort": getFuncFirstIntValue(label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort),
"getHealthCheckInterval": getFuncFirstStringValue(label.TraefikBackendHealthCheckInterval, ""),
"hasCircuitBreakerLabel": hasFuncFirst(label.TraefikBackendCircuitBreakerExpression),
"getCircuitBreakerExpression": getFuncFirstStringValue(label.TraefikBackendCircuitBreakerExpression, label.DefaultCircuitBreakerExpression),
"hasMaxConnLabels": hasMaxConnLabels,
"getMaxConnAmount": getFuncFirstInt64Value(label.TraefikBackendMaxConnAmount, math.MaxInt64),
"getMaxConnExtractorFunc": getFuncFirstStringValue(label.TraefikBackendMaxConnExtractorFunc, label.DefaultBackendMaxconnExtractorFunc),
"getHost": getHost,
"getPort": getPort,
"getCircuitBreaker": getCircuitBreaker,
"getLoadBalancer": getLoadBalancer,
"getMaxConn": getMaxConn,
"getHealthCheck": getHealthCheck,
"getServers": getServers,
// TODO Deprecated [breaking]
"getProtocol": getFuncStringValue(label.TraefikProtocol, label.DefaultProtocol),
// TODO Deprecated [breaking]
"getWeight": getFuncIntValue(label.TraefikWeight, label.DefaultWeightInt),
// TODO Deprecated [breaking]
"getLoadBalancerMethod": getFuncFirstStringValue(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod),
// TODO Deprecated [breaking]
"getSticky": getSticky,
// TODO Deprecated [breaking]
"hasStickinessLabel": getFuncFirstBoolValue(label.TraefikBackendLoadBalancerStickiness, false),
// TODO Deprecated [breaking]
"getStickinessCookieName": getFuncFirstStringValue(label.TraefikBackendLoadBalancerStickinessCookieName, label.DefaultBackendLoadbalancerStickinessCookieName),
// TODO Deprecated [breaking]
"hasHealthCheckLabels": hasFuncFirst(label.TraefikBackendHealthCheckPath),
// TODO Deprecated [breaking]
"getHealthCheckPath": getFuncFirstStringValue(label.TraefikBackendHealthCheckPath, ""),
// TODO Deprecated [breaking]
"getHealthCheckInterval": getFuncFirstStringValue(label.TraefikBackendHealthCheckInterval, ""),
// Frontend functions
"filterFrontends": filterFrontends,
"getFrontendRule": p.getFrontendRule,
"getPassHostHeader": getFuncStringValue(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
"getPassTLSCert": getFuncBoolValue(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
"getPriority": getFuncStringValue(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
"getBasicAuth": getFuncSliceString(label.TraefikFrontendAuthBasic),
"getEntryPoints": getFuncSliceString(label.TraefikFrontendEntryPoints),
"getWhitelistSourceRange": getFuncSliceString(label.TraefikFrontendWhitelistSourceRange),
"hasRedirect": hasRedirect,
"getRedirectEntryPoint": getFuncStringValue(label.TraefikFrontendRedirectEntryPoint, label.DefaultFrontendRedirectEntryPoint),
"getRedirectRegex": getFuncStringValue(label.TraefikFrontendRedirectRegex, ""),
"getRedirectReplacement": getFuncStringValue(label.TraefikFrontendRedirectReplacement, ""),
"hasErrorPages": hasPrefixFuncLabel(label.Prefix + label.BaseFrontendErrorPage),
"getErrorPages": getErrorPages,
"hasRateLimits": hasFuncLabel(label.TraefikFrontendRateLimitExtractorFunc),
"getRateLimitsExtractorFunc": getFuncStringValue(label.TraefikFrontendRateLimitExtractorFunc, ""),
"getRateLimits": getRateLimits,
// Headers
"hasHeaders": hasPrefixFuncLabel(label.TraefikFrontendHeaders),
"hasRequestHeaders": hasFuncLabel(label.TraefikFrontendRequestHeaders),
"getRequestHeaders": getFuncMapValue(label.TraefikFrontendRequestHeaders),
"hasResponseHeaders": hasFuncLabel(label.TraefikFrontendResponseHeaders),
"getResponseHeaders": getFuncMapValue(label.TraefikFrontendResponseHeaders),
"hasAllowedHostsHeaders": hasFuncLabel(label.TraefikFrontendAllowedHosts),
"getAllowedHostsHeaders": getFuncSliceString(label.TraefikFrontendAllowedHosts),
"hasHostsProxyHeaders": hasFuncLabel(label.TraefikFrontendHostsProxyHeaders),
"getHostsProxyHeaders": getFuncSliceString(label.TraefikFrontendHostsProxyHeaders),
"hasSSLRedirectHeaders": hasFuncLabel(label.TraefikFrontendSSLRedirect),
"getSSLRedirectHeaders": getFuncBoolValue(label.TraefikFrontendSSLRedirect, false),
"hasSSLTemporaryRedirectHeaders": hasFuncLabel(label.TraefikFrontendSSLTemporaryRedirect),
"getSSLTemporaryRedirectHeaders": getFuncBoolValue(label.TraefikFrontendSSLTemporaryRedirect, false),
"hasSSLHostHeaders": hasFuncLabel(label.TraefikFrontendSSLHost),
"getSSLHostHeaders": getFuncStringValue(label.TraefikFrontendSSLHost, ""),
"hasSSLProxyHeaders": hasFuncLabel(label.TraefikFrontendSSLProxyHeaders),
"getSSLProxyHeaders": getFuncMapValue(label.TraefikFrontendSSLProxyHeaders),
"hasSTSSecondsHeaders": hasFuncLabel(label.TraefikFrontendSTSSeconds),
"getSTSSecondsHeaders": getFuncInt64Value(label.TraefikFrontendSTSSeconds, 0),
"hasSTSIncludeSubdomainsHeaders": hasFuncLabel(label.TraefikFrontendSTSIncludeSubdomains),
"getSTSIncludeSubdomainsHeaders": getFuncBoolValue(label.TraefikFrontendSTSIncludeSubdomains, false),
"hasSTSPreloadHeaders": hasFuncLabel(label.TraefikFrontendSTSPreload),
"getSTSPreloadHeaders": getFuncBoolValue(label.TraefikFrontendSTSPreload, false),
"hasForceSTSHeaderHeaders": hasFuncLabel(label.TraefikFrontendForceSTSHeader),
"getForceSTSHeaderHeaders": getFuncBoolValue(label.TraefikFrontendForceSTSHeader, false),
"hasFrameDenyHeaders": hasFuncLabel(label.TraefikFrontendFrameDeny),
"getFrameDenyHeaders": getFuncBoolValue(label.TraefikFrontendFrameDeny, false),
"hasCustomFrameOptionsValueHeaders": hasFuncLabel(label.TraefikFrontendCustomFrameOptionsValue),
"getCustomFrameOptionsValueHeaders": getFuncStringValue(label.TraefikFrontendCustomFrameOptionsValue, ""),
"hasContentTypeNosniffHeaders": hasFuncLabel(label.TraefikFrontendContentTypeNosniff),
"getContentTypeNosniffHeaders": getFuncBoolValue(label.TraefikFrontendContentTypeNosniff, false),
"hasBrowserXSSFilterHeaders": hasFuncLabel(label.TraefikFrontendBrowserXSSFilter),
"getBrowserXSSFilterHeaders": getFuncBoolValue(label.TraefikFrontendBrowserXSSFilter, false),
"hasContentSecurityPolicyHeaders": hasFuncLabel(label.TraefikFrontendContentSecurityPolicy),
"getContentSecurityPolicyHeaders": getFuncStringValue(label.TraefikFrontendContentSecurityPolicy, ""),
"hasPublicKeyHeaders": hasFuncLabel(label.TraefikFrontendPublicKey),
"getPublicKeyHeaders": getFuncStringValue(label.TraefikFrontendPublicKey, ""),
"hasReferrerPolicyHeaders": hasFuncLabel(label.TraefikFrontendReferrerPolicy),
"getReferrerPolicyHeaders": getFuncStringValue(label.TraefikFrontendReferrerPolicy, ""),
"hasIsDevelopmentHeaders": hasFuncLabel(label.TraefikFrontendIsDevelopment),
"getIsDevelopmentHeaders": getFuncBoolValue(label.TraefikFrontendIsDevelopment, false),
"filterFrontends": filterFrontends,
"getFrontendRule": p.getFrontendRule,
"getPassHostHeader": getFuncBoolValue(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
"getPassTLSCert": getFuncBoolValue(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
"getPriority": getFuncIntValue(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
"getBasicAuth": getFuncSliceString(label.TraefikFrontendAuthBasic),
"getEntryPoints": getFuncSliceString(label.TraefikFrontendEntryPoints),
"getWhitelistSourceRange": getFuncSliceString(label.TraefikFrontendWhitelistSourceRange),
"getRedirect": getRedirect,
"getErrorPages": getErrorPages,
"getRateLimit": getRateLimit,
"getHeaders": getHeaders,
}
return p.GetConfiguration("templates/ecs.tmpl", ecsFuncMap, struct {
Services map[string][]ecsInstance
}{
services,
Services: services,
})
}
@ -109,23 +73,34 @@ func (p *Provider) getFrontendRule(i ecsInstance) string {
}
// TODO: Deprecated
// Deprecated replaced by Stickiness
func getSticky(instances []ecsInstance) string {
// replaced by Stickiness
// Deprecated
func getSticky(instances []ecsInstance) bool {
if hasFirst(instances, label.TraefikBackendLoadBalancerSticky) {
log.Warnf("Deprecated configuration found: %s. Please use %s.", label.TraefikBackendLoadBalancerSticky, label.TraefikBackendLoadBalancerStickiness)
}
return getFirstStringValue(instances, label.TraefikBackendLoadBalancerSticky, "false")
return getFirstBoolValue(instances, label.TraefikBackendLoadBalancerSticky, false)
}
// TODO: Deprecated
// replaced by Stickiness
// Deprecated
func getStickyOne(instance ecsInstance) bool {
if hasLabel(instance, label.TraefikBackendLoadBalancerSticky) {
log.Warnf("Deprecated configuration found: %s. Please use %s.", label.TraefikBackendLoadBalancerSticky, label.TraefikBackendLoadBalancerStickiness)
}
return getBoolValue(instance, label.TraefikBackendLoadBalancerSticky, false)
}
func getHost(i ecsInstance) string {
return *i.machine.PrivateIpAddress
return aws.StringValue(i.machine.PrivateIpAddress)
}
func getPort(i ecsInstance) string {
if value := getStringValue(i, label.TraefikPort, ""); len(value) > 0 {
return value
}
return strconv.FormatInt(*i.container.NetworkBindings[0].HostPort, 10)
return strconv.FormatInt(aws.Int64Value(i.container.NetworkBindings[0].HostPort), 10)
}
func filterFrontends(instances []ecsInstance) []ecsInstance {
@ -140,54 +115,163 @@ func filterFrontends(instances []ecsInstance) []ecsInstance {
}, instances).([]ecsInstance)
}
func hasLoadBalancerLabel(instances []ecsInstance) bool {
method := hasFirst(instances, label.TraefikBackendLoadBalancerMethod)
sticky := hasFirst(instances, label.TraefikBackendLoadBalancerSticky)
stickiness := hasFirst(instances, label.TraefikBackendLoadBalancerStickiness)
cookieName := hasFirst(instances, label.TraefikBackendLoadBalancerStickinessCookieName)
func getCircuitBreaker(instance ecsInstance) *types.CircuitBreaker {
expression := getStringValue(instance, label.TraefikBackendCircuitBreakerExpression, "")
if len(expression) == 0 {
return nil
}
return method || sticky || stickiness || cookieName
return &types.CircuitBreaker{Expression: expression}
}
func hasMaxConnLabels(instances []ecsInstance) bool {
mca := hasFirst(instances, label.TraefikBackendMaxConnAmount)
mcef := hasFirst(instances, label.TraefikBackendMaxConnExtractorFunc)
return mca && mcef
func getLoadBalancer(instance ecsInstance) *types.LoadBalancer {
if !hasPrefix(instance, label.TraefikBackendLoadBalancer) {
return nil
}
method := getStringValue(instance, label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod)
lb := &types.LoadBalancer{
Method: method,
Sticky: getStickyOne(instance),
}
if getBoolValue(instance, label.TraefikBackendLoadBalancerStickiness, false) {
cookieName := getStringValue(instance, label.TraefikBackendLoadBalancerStickinessCookieName, label.DefaultBackendLoadbalancerStickinessCookieName)
lb.Stickiness = &types.Stickiness{CookieName: cookieName}
}
return lb
}
func hasRedirect(instance ecsInstance) bool {
return hasLabel(instance, label.TraefikFrontendRedirectEntryPoint) ||
hasLabel(instance, label.TraefikFrontendRedirectRegex) && hasLabel(instance, label.TraefikFrontendRedirectReplacement)
func getMaxConn(instance ecsInstance) *types.MaxConn {
amount := getInt64Value(instance, label.TraefikBackendMaxConnAmount, math.MinInt64)
extractorFunc := getStringValue(instance, label.TraefikBackendMaxConnExtractorFunc, label.DefaultBackendMaxconnExtractorFunc)
if amount == math.MinInt64 || len(extractorFunc) == 0 {
return nil
}
return &types.MaxConn{
Amount: amount,
ExtractorFunc: extractorFunc,
}
}
func getHealthCheck(instance ecsInstance) *types.HealthCheck {
path := getStringValue(instance, label.TraefikBackendHealthCheckPath, "")
if len(path) == 0 {
return nil
}
port := getIntValue(instance, label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort)
interval := getStringValue(instance, label.TraefikBackendHealthCheckInterval, "")
return &types.HealthCheck{
Path: path,
Port: port,
Interval: interval,
}
}
func getServers(instances []ecsInstance) map[string]types.Server {
var servers map[string]types.Server
for _, instance := range instances {
if servers == nil {
servers = make(map[string]types.Server)
}
protocol := getStringValue(instance, label.TraefikProtocol, label.DefaultProtocol)
host := getHost(instance)
port := getPort(instance)
serverName := provider.Normalize(fmt.Sprintf("server-%s-%s", instance.Name, instance.ID))
servers[serverName] = types.Server{
URL: fmt.Sprintf("%s://%s:%s", protocol, host, port),
Weight: getIntValue(instance, label.TraefikWeight, 0),
}
}
return servers
}
func getRedirect(instance ecsInstance) *types.Redirect {
if hasLabel(instance, label.TraefikFrontendRedirectEntryPoint) {
return &types.Redirect{
EntryPoint: getStringValue(instance, label.TraefikFrontendRedirectEntryPoint, ""),
}
}
if hasLabel(instance, label.TraefikFrontendRedirectRegex) &&
hasLabel(instance, label.TraefikFrontendRedirectReplacement) {
return &types.Redirect{
Regex: getStringValue(instance, label.TraefikFrontendRedirectRegex, ""),
Replacement: getStringValue(instance, label.TraefikFrontendRedirectReplacement, ""),
}
}
return nil
}
func getErrorPages(instance ecsInstance) map[string]*types.ErrorPage {
labels := mapPToMap(instance.containerDefinition.DockerLabels)
if len(labels) == 0 {
return nil
}
prefix := label.Prefix + label.BaseFrontendErrorPage
return label.ParseErrorPages(labels, prefix, label.RegexpFrontendErrorPage)
}
func getRateLimits(instance ecsInstance) map[string]*types.Rate {
labels := mapPToMap(instance.containerDefinition.DockerLabels)
func getRateLimit(instance ecsInstance) *types.RateLimit {
extractorFunc := getStringValue(instance, label.TraefikFrontendRateLimitExtractorFunc, "")
if len(extractorFunc) == 0 {
return nil
}
labels := mapPToMap(instance.containerDefinition.DockerLabels)
prefix := label.Prefix + label.BaseFrontendRateLimit
return label.ParseRateSets(labels, prefix, label.RegexpFrontendRateLimit)
limits := label.ParseRateSets(labels, prefix, label.RegexpFrontendRateLimit)
return &types.RateLimit{
ExtractorFunc: extractorFunc,
RateSet: limits,
}
}
func getHeaders(instance ecsInstance) *types.Headers {
headers := &types.Headers{
CustomRequestHeaders: getMapString(instance, label.TraefikFrontendRequestHeaders),
CustomResponseHeaders: getMapString(instance, label.TraefikFrontendResponseHeaders),
SSLProxyHeaders: getMapString(instance, label.TraefikFrontendSSLProxyHeaders),
AllowedHosts: getSliceString(instance, label.TraefikFrontendAllowedHosts),
HostsProxyHeaders: getSliceString(instance, label.TraefikFrontendHostsProxyHeaders),
STSSeconds: getInt64Value(instance, label.TraefikFrontendSTSSeconds, 0),
SSLRedirect: getBoolValue(instance, label.TraefikFrontendSSLRedirect, false),
SSLTemporaryRedirect: getBoolValue(instance, label.TraefikFrontendSSLTemporaryRedirect, false),
STSIncludeSubdomains: getBoolValue(instance, label.TraefikFrontendSTSIncludeSubdomains, false),
STSPreload: getBoolValue(instance, label.TraefikFrontendSTSPreload, false),
ForceSTSHeader: getBoolValue(instance, label.TraefikFrontendForceSTSHeader, false),
FrameDeny: getBoolValue(instance, label.TraefikFrontendFrameDeny, false),
ContentTypeNosniff: getBoolValue(instance, label.TraefikFrontendContentTypeNosniff, false),
BrowserXSSFilter: getBoolValue(instance, label.TraefikFrontendBrowserXSSFilter, false),
IsDevelopment: getBoolValue(instance, label.TraefikFrontendIsDevelopment, false),
SSLHost: getStringValue(instance, label.TraefikFrontendSSLHost, ""),
CustomFrameOptionsValue: getStringValue(instance, label.TraefikFrontendCustomFrameOptionsValue, ""),
ContentSecurityPolicy: getStringValue(instance, label.TraefikFrontendContentSecurityPolicy, ""),
PublicKey: getStringValue(instance, label.TraefikFrontendPublicKey, ""),
ReferrerPolicy: getStringValue(instance, label.TraefikFrontendReferrerPolicy, ""),
}
if !headers.HasSecureHeadersDefined() && !headers.HasCustomHeadersDefined() {
return nil
}
return headers
}
// Label functions
func hasFuncLabel(labelName string) func(i ecsInstance) bool {
return func(i ecsInstance) bool {
return hasLabel(i, labelName)
}
}
func hasPrefixFuncLabel(prefix string) func(i ecsInstance) bool {
return func(i ecsInstance) bool {
return hasPrefix(i, prefix)
}
}
func getFuncStringValue(labelName string, defaultValue string) func(i ecsInstance) string {
return func(i ecsInstance) string {
return getStringValue(i, labelName, defaultValue)
@ -200,9 +284,9 @@ func getFuncBoolValue(labelName string, defaultValue bool) func(i ecsInstance) b
}
}
func getFuncInt64Value(labelName string, defaultValue int64) func(i ecsInstance) int64 {
return func(i ecsInstance) int64 {
return getInt64Value(i, labelName, defaultValue)
func getFuncIntValue(labelName string, defaultValue int) func(i ecsInstance) int {
return func(i ecsInstance) int {
return getIntValue(i, labelName, defaultValue)
}
}
@ -212,42 +296,21 @@ func getFuncSliceString(labelName string) func(i ecsInstance) []string {
}
}
func getFuncMapValue(labelName string) func(i ecsInstance) map[string]string {
return func(i ecsInstance) map[string]string {
return getMapString(i, labelName)
}
}
// Deprecated
func hasFuncFirst(labelName string) func(instances []ecsInstance) bool {
return func(instances []ecsInstance) bool {
return hasFirst(instances, labelName)
}
}
// Deprecated
func getFuncFirstStringValue(labelName string, defaultValue string) func(instances []ecsInstance) string {
return func(instances []ecsInstance) string {
return getFirstStringValue(instances, labelName, defaultValue)
}
}
func getFuncFirstIntValue(labelName string, defaultValue int) func(instances []ecsInstance) int {
return func(instances []ecsInstance) int {
if len(instances) < 0 {
return defaultValue
}
return getIntValue(instances[0], labelName, defaultValue)
}
}
func getFuncFirstInt64Value(labelName string, defaultValue int64) func(instances []ecsInstance) int64 {
return func(instances []ecsInstance) int64 {
if len(instances) < 0 {
return defaultValue
}
return getInt64Value(instances[0], labelName, defaultValue)
}
}
// Deprecated
func getFuncFirstBoolValue(labelName string, defaultValue bool) func(instances []ecsInstance) bool {
return func(instances []ecsInstance) bool {
if len(instances) < 0 {
@ -259,12 +322,12 @@ func getFuncFirstBoolValue(labelName string, defaultValue bool) func(instances [
func hasLabel(i ecsInstance, labelName string) bool {
value, ok := i.containerDefinition.DockerLabels[labelName]
return ok && value != nil && len(*value) > 0
return ok && value != nil && len(aws.StringValue(value)) > 0
}
func hasPrefix(i ecsInstance, prefix string) bool {
for name, value := range i.containerDefinition.DockerLabels {
if strings.HasPrefix(name, prefix) && value != nil && len(*value) > 0 {
if strings.HasPrefix(name, prefix) && value != nil && len(aws.StringValue(value)) > 0 {
return true
}
}
@ -276,10 +339,10 @@ func getStringValue(i ecsInstance, labelName string, defaultValue string) string
if v == nil {
return defaultValue
}
if len(*v) == 0 {
if len(aws.StringValue(v)) == 0 {
return defaultValue
}
return *v
return aws.StringValue(v)
}
return defaultValue
}
@ -301,7 +364,7 @@ func getIntValue(i ecsInstance, labelName string, defaultValue int) int {
rawValue, ok := i.containerDefinition.DockerLabels[labelName]
if ok {
if rawValue != nil {
v, err := strconv.Atoi(*rawValue)
v, err := strconv.Atoi(aws.StringValue(rawValue))
if err == nil {
return v
}
@ -314,7 +377,7 @@ func getInt64Value(i ecsInstance, labelName string, defaultValue int64) int64 {
rawValue, ok := i.containerDefinition.DockerLabels[labelName]
if ok {
if rawValue != nil {
v, err := strconv.ParseInt(*rawValue, 10, 64)
v, err := strconv.ParseInt(aws.StringValue(rawValue), 10, 64)
if err == nil {
return v
}
@ -328,10 +391,10 @@ func getSliceString(i ecsInstance, labelName string) []string {
if value == nil {
return nil
}
if len(*value) == 0 {
if len(aws.StringValue(value)) == 0 {
return nil
}
return label.SplitAndTrimString(*value, ",")
return label.SplitAndTrimString(aws.StringValue(value), ",")
}
return nil
}
@ -341,14 +404,15 @@ func getMapString(i ecsInstance, labelName string) map[string]string {
if value == nil {
return nil
}
if len(*value) == 0 {
if len(aws.StringValue(value)) == 0 {
return nil
}
return label.ParseMapValue(labelName, *value)
return label.ParseMapValue(labelName, aws.StringValue(value))
}
return nil
}
// Deprecated
func hasFirst(instances []ecsInstance, labelName string) bool {
if len(instances) == 0 {
return false
@ -356,6 +420,7 @@ func hasFirst(instances []ecsInstance, labelName string) bool {
return hasLabel(instances[0], labelName)
}
// Deprecated
func getFirstStringValue(instances []ecsInstance, labelName string, defaultValue string) string {
if len(instances) == 0 {
return defaultValue
@ -363,11 +428,19 @@ func getFirstStringValue(instances []ecsInstance, labelName string, defaultValue
return getStringValue(instances[0], labelName, defaultValue)
}
// Deprecated
func getFirstBoolValue(instances []ecsInstance, labelName string, defaultValue bool) bool {
if len(instances) == 0 {
return defaultValue
}
return getBoolValue(instances[0], labelName, defaultValue)
}
func mapPToMap(src map[string]*string) map[string]string {
result := make(map[string]string)
for key, value := range src {
if value != nil && len(*value) > 0 {
result[key] = *value
if value != nil && len(aws.StringValue(value)) > 0 {
result[key] = aws.StringValue(value)
}
}
return result

File diff suppressed because it is too large Load diff

View file

@ -1,171 +1,155 @@
[backends]
{{range $serviceName, $instances := .Services}}
{{range $serviceName, $instances := .Services }}
{{ $firstInstance := index $instances 0 }}
{{if hasCircuitBreakerLabel $instances}}
[backends.backend-{{ $serviceName }}.circuitBreaker]
expression = "{{getCircuitBreakerExpression $instances}}"
{{ $circuitBreaker := getCircuitBreaker $firstInstance }}
{{if $circuitBreaker }}
[backends."backend-{{ $serviceName }}".circuitBreaker]
expression = "{{ $circuitBreaker.Expression }}"
{{end}}
{{if hasLoadBalancerLabel $instances}}
[backends.backend-{{ $serviceName }}.loadBalancer]
method = "{{ getLoadBalancerMethod $instances}}"
sticky = {{ getSticky $instances}}
{{if hasStickinessLabel $instances}}
[backends.backend-{{ $serviceName }}.loadBalancer.stickiness]
cookieName = "{{getStickinessCookieName $instances}}"
{{ $loadBalancer := getLoadBalancer $firstInstance }}
{{if $loadBalancer }}
[backends."backend-{{ $serviceName }}".loadBalancer]
method = "{{ $loadBalancer.Method }}"
sticky = {{ $loadBalancer.Sticky }}
{{if $loadBalancer.Stickiness }}
[backends."backend-{{ $serviceName }}".loadBalancer.stickiness]
cookieName = "{{ $loadBalancer.Stickiness.CookieName }}"
{{end}}
{{end}}
{{if hasMaxConnLabels $instances}}
[backends.backend-{{ $serviceName }}.maxConn]
amount = {{getMaxConnAmount $instances}}
extractorFunc = "{{getMaxConnExtractorFunc $instances}}"
{{ $maxConn := getMaxConn $firstInstance }}
{{if $maxConn }}
[backends."backend-{{ $serviceName }}".maxConn]
extractorFunc = "{{ $maxConn.ExtractorFunc }}"
amount = {{ $maxConn.Amount }}
{{end}}
{{ if hasHealthCheckLabels $instances }}
{{ $healthCheck := getHealthCheck $firstInstance }}
{{if $healthCheck }}
[backends.backend-{{ $serviceName }}.healthCheck]
path = "{{getHealthCheckPath $instances }}"
port = {{getHealthCheckPort $instances}}
interval = "{{getHealthCheckInterval $instances }}"
path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}"
{{end}}
{{range $index, $instance := $instances}}
[backends.backend-{{ $instance.Name }}.servers.server-{{ $instance.Name }}{{ $instance.ID }}]
url = "{{ getProtocol $instance }}://{{ getHost $instance }}:{{ getPort $instance }}"
weight = {{ getWeight $instance}}
{{range $serverName, $server := getServers $instances }}
[backends.backend-{{ $serviceName }}.servers.{{ $serverName }}]
url = "{{ $server.URL }}"
weight = {{ $server.Weight }}
{{end}}
{{end}}
[frontends]
{{range $serviceName, $instances := .Services}}
{{range $instance := filterFrontends $instances}}
{{range $serviceName, $instances := .Services }}
{{range $instance := filterFrontends $instances }}
[frontends.frontend-{{ $serviceName }}]
backend = "backend-{{ $serviceName }}"
priority = {{ getPriority $instance}}
passHostHeader = {{ getPassHostHeader $instance}}
passTLSCert = {{ getPassTLSCert $instance}}
priority = {{ getPriority $instance }}
passHostHeader = {{ getPassHostHeader $instance }}
passTLSCert = {{ getPassTLSCert $instance }}
entryPoints = [{{range getEntryPoints $instance}}
entryPoints = [{{range getEntryPoints $instance }}
"{{.}}",
{{end}}]
{{if getWhitelistSourceRange $instance}}
whitelistSourceRange = [{{range getWhitelistSourceRange $instance}}
{{ $whitelistSourceRange := getWhitelistSourceRange $instance }}
{{if $whitelistSourceRange }}
whitelistSourceRange = [{{range $whitelistSourceRange }}
"{{.}}",
{{end}}]
{{end}}
basicAuth = [{{range getBasicAuth $instance}}
basicAuth = [{{range getBasicAuth $instance }}
"{{.}}",
{{end}}]
{{if hasRedirect $instance}}
{{ $redirect := getRedirect $instance }}
{{if $redirect }}
[frontends."frontend-{{ $serviceName }}".redirect]
entryPoint = "{{getRedirectEntryPoint $instance}}"
regex = "{{getRedirectRegex $instance}}"
replacement = "{{getRedirectReplacement $instance}}"
entryPoint = "{{ $redirect.EntryPoint }}"
regex = "{{ $redirect.Regex }}"
replacement = "{{ $redirect.Replacement }}"
{{end}}
{{ if hasErrorPages $instance }}
{{ $errorPages := getErrorPages $instance }}
{{if $errorPages }}
[frontends."frontend-{{ $serviceName }}".errors]
{{ range $pageName, $page := getErrorPages $instance }}
{{range $pageName, $page := $errorPages }}
[frontends."frontend-{{ $serviceName }}".errors.{{ $pageName }}]
status = [{{range $page.Status}}
status = [{{range $page.Status }}
"{{.}}",
{{end}}]
backend = "{{$page.Backend}}"
query = "{{$page.Query}}"
backend = "{{ $page.Backend }}"
query = "{{ $page.Query }}"
{{end}}
{{end}}
{{ if hasRateLimits $instance }}
{{ $rateLimit := getRateLimit $instance }}
{{if $rateLimit }}
[frontends."frontend-{{ $serviceName }}".rateLimit]
extractorFunc = "{{ getRateLimitsExtractorFunc $instance }}"
extractorFunc = "{{ $rateLimit.ExtractorFunc }}"
[frontends."frontend-{{ $serviceName }}".rateLimit.rateSet]
{{ range $limitName, $rateLimit := getRateLimits $instance }}
{{ range $limitName, $limit := $rateLimit.RateSet }}
[frontends."frontend-{{ $serviceName }}".rateLimit.rateSet.{{ $limitName }}]
period = "{{ $rateLimit.Period }}"
average = {{ $rateLimit.Average }}
burst = {{ $rateLimit.Burst }}
period = "{{ $limit.Period }}"
average = {{ $limit.Average }}
burst = {{ $limit.Burst }}
{{end}}
{{end}}
{{if hasHeaders $instance }}
{{ $headers := getHeaders $instance }}
{{if $headers }}
[frontends."frontend-{{ $serviceName }}".headers]
{{if hasSSLRedirectHeaders $instance}}
SSLRedirect = {{getSSLRedirectHeaders $instance}}
SSLRedirect = {{ $headers.SSLRedirect }}
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
SSLHost = "{{ $headers.SSLHost }}"
STSSeconds = {{ $headers.STSSeconds }}
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
STSPreload = {{ $headers.STSPreload }}
ForceSTSHeader = {{ $headers.ForceSTSHeader }}
FrameDeny = {{ $headers.FrameDeny }}
CustomFrameOptionsValue = "{{ $headers.CustomFrameOptionsValue }}"
ContentTypeNosniff = {{ $headers.ContentTypeNosniff }}
BrowserXSSFilter = {{ $headers.BrowserXSSFilter }}
ContentSecurityPolicy = "{{ $headers.ContentSecurityPolicy }}"
PublicKey = "{{ $headers.PublicKey }}"
ReferrerPolicy = "{{ $headers.ReferrerPolicy }}"
IsDevelopment = {{ $headers.IsDevelopment }}
{{if $headers.AllowedHosts }}
AllowedHosts = [{{range $headers.AllowedHosts }}
"{{.}}",
{{end}}]
{{end}}
{{if hasSSLTemporaryRedirectHeaders $instance}}
SSLTemporaryRedirect = {{getSSLTemporaryRedirectHeaders $instance}}
{{if $headers.HostsProxyHeaders }}
HostsProxyHeaders = [{{range $headers.HostsProxyHeaders }}
"{{.}}",
{{end}}]
{{end}}
{{if hasSSLHostHeaders $instance}}
SSLHost = "{{getSSLHostHeaders $instance}}"
{{end}}
{{if hasSTSSecondsHeaders $instance}}
STSSeconds = {{getSTSSecondsHeaders $instance}}
{{end}}
{{if hasSTSIncludeSubdomainsHeaders $instance}}
STSIncludeSubdomains = {{getSTSIncludeSubdomainsHeaders $instance}}
{{end}}
{{if hasSTSPreloadHeaders $instance}}
STSPreload = {{getSTSPreloadHeaders $instance}}
{{end}}
{{if hasForceSTSHeaderHeaders $instance}}
ForceSTSHeader = {{getForceSTSHeaderHeaders $instance}}
{{end}}
{{if hasFrameDenyHeaders $instance}}
FrameDeny = {{getFrameDenyHeaders $instance}}
{{end}}
{{if hasCustomFrameOptionsValueHeaders $instance}}
CustomFrameOptionsValue = "{{getCustomFrameOptionsValueHeaders $instance}}"
{{end}}
{{if hasContentTypeNosniffHeaders $instance}}
ContentTypeNosniff = {{getContentTypeNosniffHeaders $instance}}
{{end}}
{{if hasBrowserXSSFilterHeaders $instance}}
BrowserXSSFilter = {{getBrowserXSSFilterHeaders $instance}}
{{end}}
{{if hasContentSecurityPolicyHeaders $instance}}
ContentSecurityPolicy = "{{getContentSecurityPolicyHeaders $instance}}"
{{end}}
{{if hasPublicKeyHeaders $instance}}
PublicKey = "{{getPublicKeyHeaders $instance}}"
{{end}}
{{if hasReferrerPolicyHeaders $instance}}
ReferrerPolicy = "{{getReferrerPolicyHeaders $instance}}"
{{end}}
{{if hasIsDevelopmentHeaders $instance}}
IsDevelopment = {{getIsDevelopmentHeaders $instance}}
{{end}}
{{if hasRequestHeaders $instance}}
[frontends."frontend-{{ $serviceName }}".headers.customRequestHeaders]
{{range $k, $v := getRequestHeaders $instance}}
{{if $headers.CustomRequestHeaders }}
[frontends."frontend-{{ $serviceName }}".headers.customRequestHeaders]
{{range $k, $v := $headers.CustomRequestHeaders }}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
{{if hasResponseHeaders $instance}}
{{if $headers.CustomResponseHeaders }}
[frontends."frontend-{{ $serviceName }}".headers.customResponseHeaders]
{{range $k, $v := getResponseHeaders $instance}}
{{range $k, $v := $headers.CustomResponseHeaders }}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
{{if hasAllowedHostsHeaders $instance}}
[frontends."frontend-{{ $serviceName }}".headers.AllowedHosts]
{{range getAllowedHostsHeaders $instance}}
"{{.}}"
{{end}}
{{end}}
{{if hasHostsProxyHeaders $instance}}
[frontends."frontend-{{ $serviceName }}".headers.HostsProxyHeaders]
{{range getHostsProxyHeaders $instance}}
"{{.}}"
{{end}}
{{end}}
{{if hasSSLProxyHeaders $instance}}
{{if $headers.SSLProxyHeaders }}
[frontends."frontend-{{ $serviceName }}".headers.SSLProxyHeaders]
{{range $k, $v := getSSLProxyHeaders $instance}}
{{range $k, $v := $headers.SSLProxyHeaders }}
{{$k}} = "{{$v}}"
{{end}}
{{end}}