293 lines
10 KiB
Cheetah
293 lines
10 KiB
Cheetah
{{$backendServers := .Servers}}
|
|
[backends]
|
|
{{range $backendName, $backend := .Backends}}
|
|
|
|
{{ $circuitBreaker := getCircuitBreaker $backend }}
|
|
{{if $circuitBreaker }}
|
|
[backends."backend-{{ $backendName }}".circuitBreaker]
|
|
expression = "{{ $circuitBreaker.Expression }}"
|
|
{{end}}
|
|
|
|
{{ $loadBalancer := getLoadBalancer $backend }}
|
|
{{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}}
|
|
|
|
{{ $maxConn := getMaxConn $backend }}
|
|
{{if $maxConn }}
|
|
[backends."backend-{{ $backendName }}".maxConn]
|
|
extractorFunc = "{{ $maxConn.ExtractorFunc }}"
|
|
amount = {{ $maxConn.Amount }}
|
|
{{end}}
|
|
|
|
{{ $healthCheck := getHealthCheck $backend }}
|
|
{{if $healthCheck }}
|
|
[backends.backend-{{ $backendName }}.healthCheck]
|
|
path = "{{ $healthCheck.Path }}"
|
|
port = {{ $healthCheck.Port }}
|
|
interval = "{{ $healthCheck.Interval }}"
|
|
{{end}}
|
|
|
|
{{ $servers := index $backendServers $backendName }}
|
|
{{range $serverName, $server := $servers }}
|
|
{{if hasServices $server }}
|
|
{{ $services := getServiceNames $server }}
|
|
{{range $serviceIndex, $serviceName := $services }}
|
|
[backends.backend-{{ getServiceBackendName $server $serviceName }}.servers.service-{{ $serverName }}]
|
|
url = "{{ getServiceProtocol $server $serviceName }}://{{ getIPAddress $server }}:{{ getServicePort $server $serviceName }}"
|
|
weight = {{ getServiceWeight $server $serviceName }}
|
|
{{end}}
|
|
{{else}}
|
|
[backends.backend-{{ $backendName }}.servers.server-{{ $server.Name | replace "/" "" | replace "." "-" }}]
|
|
url = "{{ getProtocol $server }}://{{ getIPAddress $server }}:{{ getPort $server }}"
|
|
weight = {{ getWeight $server }}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
[frontends]
|
|
{{range $frontendName, $containers := .Frontends }}
|
|
{{$container := index $containers 0}}
|
|
|
|
{{if hasServices $container }}
|
|
{{ $services := getServiceNames $container }}
|
|
|
|
{{range $serviceIndex, $serviceName := $services }}
|
|
{{ $ServiceFrontendName := getServiceBackendName $container $serviceName }}
|
|
|
|
[frontends."frontend-{{ $ServiceFrontendName }}"]
|
|
backend = "backend-{{ $ServiceFrontendName }}"
|
|
priority = {{ getServicePriority $container $serviceName }}
|
|
passHostHeader = {{ getServicePassHostHeader $container $serviceName }}
|
|
passTLSCert = {{ getServicePassTLSCert $container $serviceName }}
|
|
|
|
entryPoints = [{{range getServiceEntryPoints $container $serviceName }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
|
|
{{ $whitelistSourceRange := getServiceWhitelistSourceRange $container $serviceName }}
|
|
{{if $whitelistSourceRange }}
|
|
whitelistSourceRange = [{{range $whitelistSourceRange }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
{{end}}
|
|
|
|
basicAuth = [{{range getServiceBasicAuth $container $serviceName }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
|
|
{{ $redirect := getServiceRedirect $container $serviceName }}
|
|
{{if $redirect }}
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".redirect]
|
|
entryPoint = "{{ $redirect.EntryPoint }}"
|
|
regex = "{{ $redirect.Regex }}"
|
|
replacement = "{{ $redirect.Replacement }}"
|
|
{{end}}
|
|
|
|
{{ $errorPages := getServiceErrorPages $container $serviceName }}
|
|
{{if $errorPages }}
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".errors]
|
|
{{ range $pageName, $page := $errorPages }}
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".errors.{{ $pageName }}]
|
|
status = [{{range $page.Status }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
backend = "{{ $page.Backend }}"
|
|
query = "{{ $page.Query }}"
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{ $rateLimit := getServiceRateLimit $container $serviceName }}
|
|
{{if $rateLimit }}
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".rateLimit]
|
|
extractorFunc = "{{ $rateLimit.ExtractorFunc }}"
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".rateLimit.rateSet]
|
|
{{range $limitName, $limit := $rateLimit.RateSet }}
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".rateLimit.rateSet.{{ $limitName }}]
|
|
period = "{{ $limit.Period }}"
|
|
average = {{ $limit.Average }}
|
|
burst = {{ $limit.Burst }}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{ $headers := getServiceHeaders $container $serviceName }}
|
|
{{if $headers }}
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".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 }}"
|
|
PublicKey = "{{ $headers.PublicKey }}"
|
|
ReferrerPolicy = "{{ $headers.ReferrerPolicy }}"
|
|
IsDevelopment = {{ $headers.IsDevelopment }}
|
|
|
|
{{if $headers.AllowedHosts }}
|
|
AllowedHosts = [{{range $headers.AllowedHosts }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
{{end}}
|
|
|
|
{{if $headers.HostsProxyHeaders }}
|
|
HostsProxyHeaders = [{{range $headers.HostsProxyHeaders }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
{{end}}
|
|
|
|
{{if $headers.CustomRequestHeaders }}
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".headers.customRequestHeaders]
|
|
{{range $k, $v := $headers.CustomRequestHeaders }}
|
|
{{$k}} = "{{$v}}"
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{if $headers.CustomResponseHeaders }}
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".headers.customResponseHeaders]
|
|
{{range $k, $v := $headers.CustomResponseHeaders }}
|
|
{{$k}} = "{{$v}}"
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{if $headers.SSLProxyHeaders }}
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".headers.SSLProxyHeaders]
|
|
{{range $k, $v := $headers.SSLProxyHeaders }}
|
|
{{$k}} = "{{$v}}"
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
[frontends."frontend-{{ $ServiceFrontendName }}".routes."service-{{ $serviceName | replace "/" "" | replace "." "-" }}"]
|
|
rule = "{{ getServiceFrontendRule $container $serviceName }}"
|
|
|
|
{{end}} ## end range services
|
|
|
|
{{else}}
|
|
|
|
[frontends."frontend-{{ $frontendName }}"]
|
|
backend = "backend-{{ getBackendName $container }}"
|
|
priority = {{ getPriority $container }}
|
|
passHostHeader = {{ getPassHostHeader $container }}
|
|
passTLSCert = {{ getPassTLSCert $container }}
|
|
|
|
entryPoints = [{{range getEntryPoints $container }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
|
|
{{ $whitelistSourceRange := getWhitelistSourceRange $container}}
|
|
{{if $whitelistSourceRange }}
|
|
whitelistSourceRange = [{{range $whitelistSourceRange }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
{{end}}
|
|
|
|
basicAuth = [{{range getBasicAuth $container }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
|
|
{{ $redirect := getRedirect $container }}
|
|
{{if $redirect }}
|
|
[frontends."frontend-{{ $frontendName }}".redirect]
|
|
entryPoint = "{{ $redirect.EntryPoint }}"
|
|
regex = "{{ $redirect.Regex }}"
|
|
replacement = "{{ $redirect.Replacement }}"
|
|
{{end}}
|
|
|
|
{{ $errorPages := getErrorPages $container }}
|
|
{{if $errorPages }}
|
|
[frontends."frontend-{{ $frontendName }}".errors]
|
|
{{range $pageName, $page := $errorPages }}
|
|
[frontends."frontend-{{ $frontendName }}".errors.{{ $pageName }}]
|
|
status = [{{range $page.Status }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
backend = "{{ $page.Backend }}"
|
|
query = "{{ $page.Query }}"
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{ $rateLimit := getRateLimit $container }}
|
|
{{if $rateLimit }}
|
|
[frontends."frontend-{{ $frontendName }}".rateLimit]
|
|
extractorFunc = "{{ $rateLimit.ExtractorFunc }}"
|
|
[frontends."frontend-{{ $frontendName }}".rateLimit.rateSet]
|
|
{{ range $limitName, $limit := $rateLimit.RateSet }}
|
|
[frontends."frontend-{{ $frontendName }}".rateLimit.rateSet.{{ $limitName }}]
|
|
period = "{{ $limit.Period }}"
|
|
average = {{ $limit.Average }}
|
|
burst = {{ $limit.Burst }}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{ $headers := getHeaders $container }}
|
|
{{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 }}"
|
|
PublicKey = "{{ $headers.PublicKey }}"
|
|
ReferrerPolicy = "{{ $headers.ReferrerPolicy }}"
|
|
IsDevelopment = {{ $headers.IsDevelopment }}
|
|
|
|
{{if $headers.AllowedHosts }}
|
|
AllowedHosts = [{{range $headers.AllowedHosts }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
{{end}}
|
|
|
|
{{if $headers.HostsProxyHeaders }}
|
|
HostsProxyHeaders = [{{range $headers.HostsProxyHeaders }}
|
|
"{{.}}",
|
|
{{end}}]
|
|
{{end}}
|
|
|
|
{{if $headers.CustomRequestHeaders }}
|
|
[frontends."frontend-{{ $frontendName }}".headers.customRequestHeaders]
|
|
{{range $k, $v := $headers.CustomRequestHeaders }}
|
|
{{$k}} = "{{$v}}"
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{if $headers.CustomResponseHeaders }}
|
|
[frontends."frontend-{{ $frontendName }}".headers.customResponseHeaders]
|
|
{{range $k, $v := $headers.CustomResponseHeaders }}
|
|
{{$k}} = "{{$v}}"
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{if $headers.SSLProxyHeaders }}
|
|
[frontends."frontend-{{ $frontendName }}".headers.SSLProxyHeaders]
|
|
{{range $k, $v := $headers.SSLProxyHeaders }}
|
|
{{$k}} = "{{$v}}"
|
|
{{end}}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
[frontends."frontend-{{ $frontendName }}".routes."route-frontend-{{ $frontendName }}"]
|
|
rule = "{{ getFrontendRule $container }}"
|
|
|
|
{{end}}
|
|
|
|
{{end}}
|