traefik/templates/docker.tmpl

177 lines
6.2 KiB
Cheetah
Raw Normal View History

{{$backendServers := .Servers}}
[backends]
2018-03-23 12:30:03 +00:00
{{range $backendName, $servers := .Servers}}
{{ $backend := index $servers 0 }}
2016-08-25 04:22:06 +00:00
2018-03-23 12:30:03 +00:00
{{ $circuitBreaker := getCircuitBreaker $backend.SegmentLabels }}
2018-01-09 15:26:03 +00:00
{{if $circuitBreaker }}
[backends."backend-{{ $backendName }}".circuitBreaker]
expression = "{{ $circuitBreaker.Expression }}"
{{end}}
2016-08-25 04:22:06 +00:00
2018-03-23 12:30:03 +00:00
{{ $loadBalancer := getLoadBalancer $backend.SegmentLabels }}
2018-01-09 15:26:03 +00:00
{{if $loadBalancer }}
[backends."backend-{{ $backendName }}".loadBalancer]
method = "{{ $loadBalancer.Method }}"
sticky = {{ $loadBalancer.Sticky }}
{{if $loadBalancer.Stickiness }}
[backends."backend-{{ $backendName }}".loadBalancer.stickiness]
cookieName = "{{ $loadBalancer.Stickiness.CookieName }}"
{{end}}
{{end}}
2018-03-23 12:30:03 +00:00
{{ $maxConn := getMaxConn $backend.SegmentLabels }}
2018-01-09 15:26:03 +00:00
{{if $maxConn }}
[backends."backend-{{ $backendName }}".maxConn]
extractorFunc = "{{ $maxConn.ExtractorFunc }}"
amount = {{ $maxConn.Amount }}
{{end}}
2018-03-23 12:30:03 +00:00
{{ $healthCheck := getHealthCheck $backend.SegmentLabels }}
2018-01-09 15:26:03 +00:00
{{if $healthCheck }}
2018-03-07 21:10:04 +00:00
[backends."backend-{{ $backendName }}".healthCheck]
2018-01-09 15:26:03 +00:00
path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}"
2017-12-16 12:24:07 +00:00
{{end}}
2018-03-23 12:30:03 +00:00
{{ $buffering := getBuffering $backend.SegmentLabels }}
2018-01-31 14:32:04 +00:00
{{if $buffering }}
2018-03-07 21:10:04 +00:00
[backends."backend-{{ $backendName }}".buffering]
2018-01-31 14:32:04 +00:00
maxRequestBodyBytes = {{ $buffering.MaxRequestBodyBytes }}
memRequestBodyBytes = {{ $buffering.MemRequestBodyBytes }}
maxResponseBodyBytes = {{ $buffering.MaxResponseBodyBytes }}
memResponseBodyBytes = {{ $buffering.MemResponseBodyBytes }}
retryExpression = "{{ $buffering.RetryExpression }}"
{{end}}
2018-03-23 12:30:03 +00:00
{{range $serverName, $server := getServers $servers }}
[backends."backend-{{ $backendName }}".servers."{{ $serverName }}"]
url = "{{ $server.URL }}"
weight = {{ $server.Weight }}
{{end}}
{{end}}
2015-09-02 19:13:25 +00:00
[frontends]
2018-01-09 15:26:03 +00:00
{{range $frontendName, $containers := .Frontends }}
2018-03-23 12:30:03 +00:00
{{ $container := index $containers 0 }}
2018-01-09 15:26:03 +00:00
[frontends."frontend-{{ $frontendName }}"]
backend = "backend-{{ getBackendName $container }}"
2018-03-23 12:30:03 +00:00
priority = {{ getPriority $container.SegmentLabels }}
passHostHeader = {{ getPassHostHeader $container.SegmentLabels }}
passTLSCert = {{ getPassTLSCert $container.SegmentLabels }}
2018-03-23 12:30:03 +00:00
entryPoints = [{{range getEntryPoints $container.SegmentLabels }}
"{{.}}",
{{end}}]
2017-12-15 10:48:03 +00:00
2018-03-23 12:30:03 +00:00
basicAuth = [{{range getBasicAuth $container.SegmentLabels }}
"{{.}}",
{{end}}]
{{ $whitelist := getWhiteList $container.SegmentLabels }}
{{if $whitelist }}
[frontends."frontend-{{ $frontendName }}".whiteList]
sourceRange = [{{range $whitelist.SourceRange }}
"{{.}}",
{{end}}]
useXForwardedFor = {{ $whitelist.UseXForwardedFor }}
{{end}}
2018-03-23 12:30:03 +00:00
{{ $redirect := getRedirect $container.SegmentLabels }}
2018-01-09 15:26:03 +00:00
{{if $redirect }}
[frontends."frontend-{{ $frontendName }}".redirect]
entryPoint = "{{ $redirect.EntryPoint }}"
regex = "{{ $redirect.Regex }}"
replacement = "{{ $redirect.Replacement }}"
2018-01-31 18:10:04 +00:00
permanent = {{ $redirect.Permanent }}
2017-11-22 18:40:04 +00:00
{{end}}
2018-03-23 12:30:03 +00:00
{{ $errorPages := getErrorPages $container.SegmentLabels }}
2018-01-09 15:26:03 +00:00
{{if $errorPages }}
[frontends."frontend-{{ $frontendName }}".errors]
{{range $pageName, $page := $errorPages }}
2018-03-07 21:10:04 +00:00
[frontends."frontend-{{ $frontendName }}".errors."{{ $pageName }}"]
2018-01-09 15:26:03 +00:00
status = [{{range $page.Status }}
2017-12-18 15:26:04 +00:00
"{{.}}",
{{end}}]
2018-01-09 15:26:03 +00:00
backend = "{{ $page.Backend }}"
query = "{{ $page.Query }}"
2017-12-18 15:26:04 +00:00
{{end}}
{{end}}
2018-03-23 12:30:03 +00:00
{{ $rateLimit := getRateLimit $container.SegmentLabels }}
2018-01-09 15:26:03 +00:00
{{if $rateLimit }}
[frontends."frontend-{{ $frontendName }}".rateLimit]
extractorFunc = "{{ $rateLimit.ExtractorFunc }}"
[frontends."frontend-{{ $frontendName }}".rateLimit.rateSet]
2018-03-23 12:30:03 +00:00
{{ range $limitName, $limit := $rateLimit.RateSet }}
2018-03-07 21:10:04 +00:00
[frontends."frontend-{{ $frontendName }}".rateLimit.rateSet."{{ $limitName }}"]
2018-01-09 15:26:03 +00:00
period = "{{ $limit.Period }}"
average = {{ $limit.Average }}
burst = {{ $limit.Burst }}
2017-12-18 17:06:12 +00:00
{{end}}
{{end}}
2018-03-23 12:30:03 +00:00
{{ $headers := getHeaders $container.SegmentLabels }}
2018-01-09 15:26:03 +00:00
{{if $headers }}
[frontends."frontend-{{ $frontendName }}".headers]
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 }}"
2018-03-23 12:30:03 +00:00
CustomBrowserXSSValue = "{{ $headers.CustomBrowserXSSValue }}"
2018-01-09 15:26:03 +00:00
PublicKey = "{{ $headers.PublicKey }}"
ReferrerPolicy = "{{ $headers.ReferrerPolicy }}"
IsDevelopment = {{ $headers.IsDevelopment }}
{{if $headers.AllowedHosts }}
AllowedHosts = [{{range $headers.AllowedHosts }}
2018-01-02 08:42:03 +00:00
"{{.}}",
{{end}}]
{{end}}
2018-01-09 15:26:03 +00:00
{{if $headers.HostsProxyHeaders }}
HostsProxyHeaders = [{{range $headers.HostsProxyHeaders }}
2018-01-02 08:42:03 +00:00
"{{.}}",
{{end}}]
{{end}}
2018-01-09 15:26:03 +00:00
{{if $headers.CustomRequestHeaders }}
[frontends."frontend-{{ $frontendName }}".headers.customRequestHeaders]
{{range $k, $v := $headers.CustomRequestHeaders }}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
2018-01-02 08:42:03 +00:00
2018-01-09 15:26:03 +00:00
{{if $headers.CustomResponseHeaders }}
[frontends."frontend-{{ $frontendName }}".headers.customResponseHeaders]
{{range $k, $v := $headers.CustomResponseHeaders }}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
2018-01-02 08:42:03 +00:00
2018-01-09 15:26:03 +00:00
{{if $headers.SSLProxyHeaders }}
[frontends."frontend-{{ $frontendName }}".headers.SSLProxyHeaders]
{{range $k, $v := $headers.SSLProxyHeaders }}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
2018-03-23 12:30:03 +00:00
2017-11-22 18:40:04 +00:00
{{end}}
2018-01-09 15:26:03 +00:00
[frontends."frontend-{{ $frontendName }}".routes."route-frontend-{{ $frontendName }}"]
rule = "{{ getFrontendRule $container }}"
2015-10-23 16:59:08 +00:00
{{end}}