Override health check scheme

This commit is contained in:
Ludovic Fernandez 2018-05-14 12:08:03 +02:00 committed by Traefiker Bot
parent b7d20496f3
commit df11e67bb4
33 changed files with 194 additions and 104 deletions

View file

@ -164,6 +164,7 @@ var _templatesConsul_catalogTmpl = []byte(`[backends]
{{ $healthCheck := getHealthCheck $service.TraefikLabels }} {{ $healthCheck := getHealthCheck $service.TraefikLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."backend-{{ $backendName }}".healthCheck] [backends."backend-{{ $backendName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"
@ -573,6 +574,7 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
{{ $healthCheck := getHealthCheck $backend.SegmentLabels }} {{ $healthCheck := getHealthCheck $backend.SegmentLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."backend-{{ $backendName }}".healthCheck] [backends."backend-{{ $backendName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"
@ -833,6 +835,7 @@ var _templatesEcsTmpl = []byte(`[backends]
{{ $healthCheck := getHealthCheck $firstInstance.TraefikLabels }} {{ $healthCheck := getHealthCheck $firstInstance.TraefikLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."backend-{{ $serviceName }}".healthCheck] [backends."backend-{{ $serviceName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"
@ -1252,6 +1255,7 @@ var _templatesKvTmpl = []byte(`[backends]
{{ $healthCheck := getHealthCheck $backend }} {{ $healthCheck := getHealthCheck $backend }}
{{if $healthCheck }} {{if $healthCheck }}
[backends.{{ $backendName }}.healthCheck] [backends.{{ $backendName }}.healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"
@ -1554,6 +1558,7 @@ var _templatesMarathonTmpl = []byte(`{{ $apps := .Applications }}
{{ $healthCheck := getHealthCheck $app.SegmentLabels }} {{ $healthCheck := getHealthCheck $app.SegmentLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."{{ $backendName }}".healthCheck] [backends."{{ $backendName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"
@ -1800,6 +1805,7 @@ var _templatesMesosTmpl = []byte(`[backends]
{{ $healthCheck := getHealthCheck $app.TraefikLabels }} {{ $healthCheck := getHealthCheck $app.TraefikLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."backend-{{ $backendName }}".healthCheck] [backends."backend-{{ $backendName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"
@ -2100,6 +2106,7 @@ var _templatesRancherTmpl = []byte(`{{ $backendServers := .Backends }}
{{ $healthCheck := getHealthCheck $backend.SegmentLabels }} {{ $healthCheck := getHealthCheck $backend.SegmentLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."backend-{{ $backendName }}".healthCheck] [backends."backend-{{ $backendName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"

View file

@ -471,7 +471,7 @@ For example:
interval = "10s" interval = "10s"
``` ```
To use a different port for the healthcheck: To use a different port for the health check:
```toml ```toml
[backends] [backends]
[backends.backend1] [backends.backend1]
@ -481,7 +481,18 @@ To use a different port for the healthcheck:
port = 8080 port = 8080
``` ```
Additional http headers and hostname to healthcheck request can be specified, for instance:
To use a different scheme for the health check:
```toml
[backends]
[backends.backend1]
[backends.backend1.healthcheck]
path = "/health"
interval = "10s"
scheme = "http"
```
Additional http headers and hostname to health check request can be specified, for instance:
```toml ```toml
[backends] [backends]
[backends.backend1] [backends.backend1]
@ -491,8 +502,8 @@ Additional http headers and hostname to healthcheck request can be specified, fo
hostname = "myhost.com" hostname = "myhost.com"
port = 8080 port = 8080
[backends.backend1.healthcheck.headers] [backends.backend1.healthcheck.headers]
mycustomheader = "foo" My-Custom-Header = "foo"
myheader2 = "bar" My-Header = "bar"
``` ```
## Configuration ## Configuration

View file

@ -99,8 +99,9 @@ Additional settings can be defined using Consul Catalog tags.
| `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. | | `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. |
| `<prefix>.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend. ex: `NetworkErrorRatio() > 0.` | | `<prefix>.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend. ex: `NetworkErrorRatio() > 0.` |
| `<prefix>.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. | | `<prefix>.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. |
| `<prefix>.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `<prefix>.backend.healthcheck.interval=1s` | Define the health check interval. | | `<prefix>.backend.healthcheck.interval=1s` | Define the health check interval. |
| `<prefix>.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.scheme=http` | Override the server URL scheme. |
| `<prefix>.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. | | `<prefix>.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. |
| `<prefix>.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> | | `<prefix>.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> |
| `<prefix>.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm. | | `<prefix>.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm. |

View file

@ -209,8 +209,9 @@ Labels can be used on containers to override default behavior.
| `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. | | `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. |
| `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend | | `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend |
| `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. | | `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. |
| `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.interval=1s` | Define the health check interval. | | `traefik.backend.healthcheck.interval=1s` | Define the health check interval. |
| `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.scheme=http` | Override the server URL scheme. |
| `traefik.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. | | `traefik.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. |
| `traefik.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> | | `traefik.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> |
| `traefik.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm | | `traefik.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm |

View file

@ -149,8 +149,9 @@ Labels can be used on task containers to override default behaviour:
| `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. | | `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. |
| `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend | | `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend |
| `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. | | `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. |
| `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.interval=1s` | Define the health check interval. (Default: 30s) | | `traefik.backend.healthcheck.interval=1s` | Define the health check interval. (Default: 30s) |
| `traefik.backend.healthcheck.scheme=http` | Override the server URL scheme. |
| `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. | | `traefik.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. |
| `traefik.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> | | `traefik.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> |
| `traefik.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm | | `traefik.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm |

View file

@ -37,6 +37,11 @@ Træfik can be configured with a file.
path = "/health" path = "/health"
port = 88 port = 88
interval = "30s" interval = "30s"
scheme = "http"
hostname = "myhost.com"
[backends.backend1.healthcheck.headers]
My-Custom-Header = "foo"
My-Header = "bar"
[backends.backend2] [backends.backend2]
# ... # ...

View file

@ -185,8 +185,9 @@ The following labels can be defined on Marathon applications. They adjust the be
| `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. | | `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. |
| `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend | | `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend |
| `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. | | `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. |
| `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.interval=1s` | Define the health check interval. (Default: 30s) | | `traefik.backend.healthcheck.interval=1s` | Define the health check interval. (Default: 30s) |
| `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.scheme=http` | Override the server URL scheme. |
| `traefik.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. | | `traefik.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. |
| `traefik.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> | | `traefik.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> |
| `traefik.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm | | `traefik.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm |

View file

@ -122,8 +122,9 @@ The following labels can be defined on Mesos tasks. They adjust the behavior for
| `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. | | `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. |
| `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend | | `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend |
| `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. | | `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. |
| `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.interval=1s` | Define the health check interval. (Default: 30s) | | `traefik.backend.healthcheck.interval=1s` | Define the health check interval. (Default: 30s) |
| `traefik.backend.healthcheck.scheme=http` | Override the server URL scheme. |
| `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. | | `traefik.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. |
| `traefik.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> | | `traefik.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> |
| `traefik.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm | | `traefik.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm |

View file

@ -153,8 +153,9 @@ Labels can be used on task containers to override default behavior:
| `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. | | `traefik.backend.buffering.retryExpression=EXPR` | See [buffering](/configuration/commons/#buffering) section. |
| `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend | | `traefik.backend.circuitbreaker.expression=EXPR` | Create a [circuit breaker](/basics/#backends) to be used against the backend |
| `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. | | `traefik.backend.healthcheck.path=/health` | Enable health check for the backend, hitting the container at `path`. |
| `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.interval=1s` | Define the health check interval. | | `traefik.backend.healthcheck.interval=1s` | Define the health check interval. |
| `traefik.backend.healthcheck.port=8080` | Allow to use a different port for the health check. |
| `traefik.backend.healthcheck.scheme=http` | Override the server URL scheme. |
| `traefik.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. | | `traefik.backend.healthcheck.hostname=foobar.com` | Define the health check hostname. |
| `traefik.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> | | `traefik.backend.healthcheck.headers=EXPR` | Define the health check request headers <br>Format: <code>HEADER:value&vert;&vert;HEADER2:value2</code> |
| `traefik.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm | | `traefik.backend.loadbalancer.method=drr` | Override the default `wrr` load balancer algorithm |

View file

@ -31,6 +31,7 @@ func GetHealthCheck(metrics metricsRegistry) *HealthCheck {
type Options struct { type Options struct {
Headers map[string]string Headers map[string]string
Hostname string Hostname string
Scheme string
Path string Path string
Port int Port int
Transport http.RoundTripper Transport http.RoundTripper
@ -50,7 +51,7 @@ type BackendHealthCheck struct {
requestTimeout time.Duration requestTimeout time.Duration
} }
//HealthCheck struct // HealthCheck struct
type HealthCheck struct { type HealthCheck struct {
Backends map[string]*BackendHealthCheck Backends map[string]*BackendHealthCheck
metrics metricsRegistry metrics metricsRegistry
@ -71,8 +72,8 @@ func newHealthCheck(metrics metricsRegistry) *HealthCheck {
} }
} }
// metricsRegistry is a local interface in the healthcheck package, exposing only the required metrics // metricsRegistry is a local interface in the health check package, exposing only the required metrics
// necessary for the healthcheck package. This makes it easier for the tests. // necessary for the health check package. This makes it easier for the tests.
type metricsRegistry interface { type metricsRegistry interface {
BackendServerUpGauge() metrics.Gauge BackendServerUpGauge() metrics.Gauge
} }
@ -152,15 +153,18 @@ func (hc *HealthCheck) checkBackend(backend *BackendHealthCheck) {
} }
func (b *BackendHealthCheck) newRequest(serverURL *url.URL) (*http.Request, error) { func (b *BackendHealthCheck) newRequest(serverURL *url.URL) (*http.Request, error) {
if b.Port == 0 {
return http.NewRequest(http.MethodGet, serverURL.String()+b.Path, nil)
}
// copy the url and add the port to the host
u := &url.URL{} u := &url.URL{}
*u = *serverURL *u = *serverURL
u.Host = net.JoinHostPort(u.Hostname(), strconv.Itoa(b.Port))
u.Path = u.Path + b.Path if len(b.Scheme) > 0 {
u.Scheme = b.Scheme
}
if b.Port != 0 {
u.Host = net.JoinHostPort(u.Hostname(), strconv.Itoa(b.Port))
}
u.Path += b.Path
return http.NewRequest(http.MethodGet, u.String(), nil) return http.NewRequest(http.MethodGet, u.String(), nil)
} }

View file

@ -134,40 +134,57 @@ func TestSetBackendsConfiguration(t *testing.T) {
func TestNewRequest(t *testing.T) { func TestNewRequest(t *testing.T) {
testCases := []struct { testCases := []struct {
desc string desc string
host string serverURL string
port int options Options
path string expected string
expected string
}{ }{
{ {
desc: "no port override", desc: "no port override",
host: "backend1:80", serverURL: "http://backend1:80",
port: 0, options: Options{
path: "/test", Path: "/test",
Port: 0,
},
expected: "http://backend1:80/test", expected: "http://backend1:80/test",
}, },
{ {
desc: "port override", desc: "port override",
host: "backend2:80", serverURL: "http://backend2:80",
port: 8080, options: Options{
path: "/test", Path: "/test",
Port: 8080,
},
expected: "http://backend2:8080/test", expected: "http://backend2:8080/test",
}, },
{ {
desc: "no port override with no port in host", desc: "no port override with no port in server URL",
host: "backend1", serverURL: "http://backend1",
port: 0, options: Options{
path: "/health", Path: "/health",
Port: 0,
},
expected: "http://backend1/health", expected: "http://backend1/health",
}, },
{ {
desc: "port override with no port in host", desc: "port override with no port in server URL",
host: "backend2", serverURL: "http://backend2",
port: 8080, options: Options{
path: "/health", Path: "/health",
Port: 8080,
},
expected: "http://backend2:8080/health", expected: "http://backend2:8080/health",
}, },
{
desc: "scheme override",
serverURL: "https://backend1:80",
options: Options{
Scheme: "http",
Path: "/test",
Port: 0,
},
expected: "http://backend1:80/test",
},
} }
for _, test := range testCases { for _, test := range testCases {
@ -175,16 +192,10 @@ func TestNewRequest(t *testing.T) {
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
t.Parallel() t.Parallel()
backend := NewBackendHealthCheck( backend := NewBackendHealthCheck(test.options, "backendName")
Options{
Path: test.path,
Port: test.port,
}, "backendName")
u := &url.URL{ u, err := url.Parse(test.serverURL)
Scheme: "http", require.NoError(t, err)
Host: test.host,
}
req, err := backend.newRequest(u) req, err := backend.newRequest(u)
require.NoError(t, err, "failed to create new backend request") require.NoError(t, err, "failed to create new backend request")
@ -194,54 +205,53 @@ func TestNewRequest(t *testing.T) {
} }
} }
func TestNewRequestWithAddHeaders(t *testing.T) { func TestAddHeadersAndHost(t *testing.T) {
testCases := []struct { testCases := []struct {
desc string desc string
host string serverURL string
headers map[string]string options Options
hostname string
port int
path string
expectedHostname string expectedHostname string
expectedHeader string expectedHeader string
}{ }{
{ {
desc: "override hostname", desc: "override hostname",
host: "backend1:80", serverURL: "http://backend1:80",
headers: map[string]string{}, options: Options{
hostname: "myhost", Hostname: "myhost",
port: 0, Path: "/",
path: "/", },
expectedHostname: "myhost", expectedHostname: "myhost",
expectedHeader: "", expectedHeader: "",
}, },
{ {
desc: "not override hostname", desc: "not override hostname",
host: "backend1:80", serverURL: "http://backend1:80",
headers: map[string]string{}, options: Options{
hostname: "", Hostname: "",
port: 0, Path: "/",
path: "/", },
expectedHostname: "backend1:80", expectedHostname: "backend1:80",
expectedHeader: "", expectedHeader: "",
}, },
{ {
desc: "custom header", desc: "custom header",
host: "backend1:80", serverURL: "http://backend1:80",
headers: map[string]string{"Custom-Header": "foo"}, options: Options{
hostname: "", Headers: map[string]string{"Custom-Header": "foo"},
port: 0, Hostname: "",
path: "/", Path: "/",
},
expectedHostname: "backend1:80", expectedHostname: "backend1:80",
expectedHeader: "foo", expectedHeader: "foo",
}, },
{ {
desc: "custom header with host override", desc: "custom header with hostname override",
host: "backend1:80", serverURL: "http://backend1:80",
headers: map[string]string{"Custom-Header": "foo"}, options: Options{
hostname: "myhost", Headers: map[string]string{"Custom-Header": "foo"},
port: 0, Hostname: "myhost",
path: "/", Path: "/",
},
expectedHostname: "myhost", expectedHostname: "myhost",
expectedHeader: "foo", expectedHeader: "foo",
}, },
@ -252,26 +262,17 @@ func TestNewRequestWithAddHeaders(t *testing.T) {
t.Run(test.desc, func(t *testing.T) { t.Run(test.desc, func(t *testing.T) {
t.Parallel() t.Parallel()
backend := NewBackendHealthCheck( backend := NewBackendHealthCheck(test.options, "backendName")
Options{
Hostname: test.hostname,
Path: test.path,
Port: test.port,
Headers: test.headers,
}, "backendName")
u := &url.URL{ u, err := url.Parse(test.serverURL)
Scheme: "http", require.NoError(t, err)
Host: test.host,
}
req, err := backend.newRequest(u) req, err := backend.newRequest(u)
if err != nil { require.NoError(t, err, "failed to create new backend request")
t.Fatalf("failed to create new backend request: %s", err)
}
req = backend.addHeadersAndHost(req) req = backend.addHeadersAndHost(req)
assert.Equal(t, "http://backend1:80/", req.URL.String())
assert.Equal(t, test.expectedHostname, req.Host) assert.Equal(t, test.expectedHostname, req.Host)
assert.Equal(t, test.expectedHeader, req.Header.Get("Custom-Header")) assert.Equal(t, test.expectedHeader, req.Header.Get("Custom-Header"))
}) })

View file

@ -126,6 +126,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
label.TraefikBackendCircuitBreakerExpression + "=NetworkErrorRatio() > 0.5", label.TraefikBackendCircuitBreakerExpression + "=NetworkErrorRatio() > 0.5",
label.TraefikBackendHealthCheckPath + "=/health", label.TraefikBackendHealthCheckPath + "=/health",
label.TraefikBackendHealthCheckScheme + "=http",
label.TraefikBackendHealthCheckPort + "=880", label.TraefikBackendHealthCheckPort + "=880",
label.TraefikBackendHealthCheckInterval + "=6", label.TraefikBackendHealthCheckInterval + "=6",
label.TraefikBackendHealthCheckHostname + "=foo.com", label.TraefikBackendHealthCheckHostname + "=foo.com",
@ -356,6 +357,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
ExtractorFunc: "client.ip", ExtractorFunc: "client.ip",
}, },
HealthCheck: &types.HealthCheck{ HealthCheck: &types.HealthCheck{
Scheme: "http",
Path: "/health", Path: "/health",
Port: 880, Port: 880,
Interval: "6", Interval: "6",

View file

@ -98,6 +98,7 @@ func TestDockerBuildConfiguration(t *testing.T) {
label.TraefikBackend: "foobar", label.TraefikBackend: "foobar",
label.TraefikBackendCircuitBreakerExpression: "NetworkErrorRatio() > 0.5", label.TraefikBackendCircuitBreakerExpression: "NetworkErrorRatio() > 0.5",
label.TraefikBackendHealthCheckScheme: "http",
label.TraefikBackendHealthCheckPath: "/health", label.TraefikBackendHealthCheckPath: "/health",
label.TraefikBackendHealthCheckPort: "880", label.TraefikBackendHealthCheckPort: "880",
label.TraefikBackendHealthCheckInterval: "6", label.TraefikBackendHealthCheckInterval: "6",
@ -294,6 +295,7 @@ func TestDockerBuildConfiguration(t *testing.T) {
ExtractorFunc: "client.ip", ExtractorFunc: "client.ip",
}, },
HealthCheck: &types.HealthCheck{ HealthCheck: &types.HealthCheck{
Scheme: "http",
Path: "/health", Path: "/health",
Port: 880, Port: 880,
Interval: "6", Interval: "6",

View file

@ -107,6 +107,7 @@ func TestSwarmBuildConfiguration(t *testing.T) {
label.TraefikBackend: "foobar", label.TraefikBackend: "foobar",
label.TraefikBackendCircuitBreakerExpression: "NetworkErrorRatio() > 0.5", label.TraefikBackendCircuitBreakerExpression: "NetworkErrorRatio() > 0.5",
label.TraefikBackendHealthCheckScheme: "http",
label.TraefikBackendHealthCheckPath: "/health", label.TraefikBackendHealthCheckPath: "/health",
label.TraefikBackendHealthCheckPort: "880", label.TraefikBackendHealthCheckPort: "880",
label.TraefikBackendHealthCheckInterval: "6", label.TraefikBackendHealthCheckInterval: "6",
@ -300,6 +301,7 @@ func TestSwarmBuildConfiguration(t *testing.T) {
ExtractorFunc: "client.ip", ExtractorFunc: "client.ip",
}, },
HealthCheck: &types.HealthCheck{ HealthCheck: &types.HealthCheck{
Scheme: "http",
Path: "/health", Path: "/health",
Port: 880, Port: 880,
Interval: "6", Interval: "6",

View file

@ -135,9 +135,12 @@ func TestBuildConfiguration(t *testing.T) {
label.TraefikBackend: aws.String("foobar"), label.TraefikBackend: aws.String("foobar"),
label.TraefikBackendCircuitBreakerExpression: aws.String("NetworkErrorRatio() > 0.5"), label.TraefikBackendCircuitBreakerExpression: aws.String("NetworkErrorRatio() > 0.5"),
label.TraefikBackendHealthCheckScheme: aws.String("http"),
label.TraefikBackendHealthCheckPath: aws.String("/health"), label.TraefikBackendHealthCheckPath: aws.String("/health"),
label.TraefikBackendHealthCheckPort: aws.String("880"), label.TraefikBackendHealthCheckPort: aws.String("880"),
label.TraefikBackendHealthCheckInterval: aws.String("6"), label.TraefikBackendHealthCheckInterval: aws.String("6"),
label.TraefikBackendHealthCheckHostname: aws.String("foo.com"),
label.TraefikBackendHealthCheckHeaders: aws.String("Foo:bar || Bar:foo"),
label.TraefikBackendLoadBalancerMethod: aws.String("drr"), label.TraefikBackendLoadBalancerMethod: aws.String("drr"),
label.TraefikBackendLoadBalancerSticky: aws.String("true"), label.TraefikBackendLoadBalancerSticky: aws.String("true"),
label.TraefikBackendLoadBalancerStickiness: aws.String("true"), label.TraefikBackendLoadBalancerStickiness: aws.String("true"),
@ -238,9 +241,15 @@ func TestBuildConfiguration(t *testing.T) {
ExtractorFunc: "client.ip", ExtractorFunc: "client.ip",
}, },
HealthCheck: &types.HealthCheck{ HealthCheck: &types.HealthCheck{
Scheme: "http",
Path: "/health", Path: "/health",
Port: 880, Port: 880,
Interval: "6", Interval: "6",
Hostname: "foo.com",
Headers: map[string]string{
"Foo": "bar",
"Bar": "foo",
},
}, },
Buffering: &types.Buffering{ Buffering: &types.Buffering{
MaxResponseBodyBytes: 10485760, MaxResponseBodyBytes: 10485760,

View file

@ -3,6 +3,7 @@ package kv
const ( const (
pathBackends = "/backends/" pathBackends = "/backends/"
pathBackendCircuitBreakerExpression = "/circuitbreaker/expression" pathBackendCircuitBreakerExpression = "/circuitbreaker/expression"
pathBackendHealthCheckScheme = "/healthcheck/scheme"
pathBackendHealthCheckPath = "/healthcheck/path" pathBackendHealthCheckPath = "/healthcheck/path"
pathBackendHealthCheckPort = "/healthcheck/port" pathBackendHealthCheckPort = "/healthcheck/port"
pathBackendHealthCheckInterval = "/healthcheck/interval" pathBackendHealthCheckInterval = "/healthcheck/interval"

View file

@ -301,17 +301,19 @@ func (p *Provider) getHealthCheck(rootPath string) *types.HealthCheck {
return nil return nil
} }
scheme := p.get("", rootPath, pathBackendHealthCheckScheme)
port := p.getInt(label.DefaultBackendHealthCheckPort, rootPath, pathBackendHealthCheckPort) port := p.getInt(label.DefaultBackendHealthCheckPort, rootPath, pathBackendHealthCheckPort)
interval := p.get("30s", rootPath, pathBackendHealthCheckInterval) interval := p.get("30s", rootPath, pathBackendHealthCheckInterval)
hostname := p.get("", rootPath, pathBackendHealthCheckHostname) hostname := p.get("", rootPath, pathBackendHealthCheckHostname)
headers := p.getMap(rootPath, pathBackendHealthCheckHeaders) headers := p.getMap(rootPath, pathBackendHealthCheckHeaders)
return &types.HealthCheck{ return &types.HealthCheck{
Hostname: hostname, Scheme: scheme,
Headers: headers,
Path: path, Path: path,
Port: port, Port: port,
Interval: interval, Interval: interval,
Hostname: hostname,
Headers: headers,
} }
} }

View file

@ -71,9 +71,13 @@ func TestProviderBuildConfiguration(t *testing.T) {
withPair(pathBackendLoadBalancerSticky, "true"), withPair(pathBackendLoadBalancerSticky, "true"),
withPair(pathBackendLoadBalancerStickiness, "true"), withPair(pathBackendLoadBalancerStickiness, "true"),
withPair(pathBackendLoadBalancerStickinessCookieName, "tomate"), withPair(pathBackendLoadBalancerStickinessCookieName, "tomate"),
withPair(pathBackendHealthCheckScheme, "http"),
withPair(pathBackendHealthCheckPath, "/health"), withPair(pathBackendHealthCheckPath, "/health"),
withPair(pathBackendHealthCheckPort, "80"), withPair(pathBackendHealthCheckPort, "80"),
withPair(pathBackendHealthCheckInterval, "30s"), withPair(pathBackendHealthCheckInterval, "30s"),
withPair(pathBackendHealthCheckHostname, "foo.com"),
withPair(pathBackendHealthCheckHeaders+"Foo", "bar"),
withPair(pathBackendHealthCheckHeaders+"Bar", "foo"),
withPair(pathBackendMaxConnAmount, "5"), withPair(pathBackendMaxConnAmount, "5"),
withPair(pathBackendMaxConnExtractorFunc, "client.ip"), withPair(pathBackendMaxConnExtractorFunc, "client.ip"),
withPair(pathBackendBufferingMaxResponseBodyBytes, "10485760"), withPair(pathBackendBufferingMaxResponseBodyBytes, "10485760"),
@ -167,9 +171,15 @@ func TestProviderBuildConfiguration(t *testing.T) {
ExtractorFunc: "client.ip", ExtractorFunc: "client.ip",
}, },
HealthCheck: &types.HealthCheck{ HealthCheck: &types.HealthCheck{
Scheme: "http",
Path: "/health", Path: "/health",
Port: 80, Port: 80,
Interval: "30s", Interval: "30s",
Hostname: "foo.com",
Headers: map[string]string{
"Foo": "bar",
"Bar": "foo",
},
}, },
Buffering: &types.Buffering{ Buffering: &types.Buffering{
MaxResponseBodyBytes: 10485760, MaxResponseBodyBytes: 10485760,

View file

@ -14,6 +14,7 @@ const (
SuffixBackendID = "backend.id" SuffixBackendID = "backend.id"
SuffixBackendCircuitBreaker = "backend.circuitbreaker" SuffixBackendCircuitBreaker = "backend.circuitbreaker"
SuffixBackendCircuitBreakerExpression = "backend.circuitbreaker.expression" SuffixBackendCircuitBreakerExpression = "backend.circuitbreaker.expression"
SuffixBackendHealthCheckScheme = "backend.healthcheck.scheme"
SuffixBackendHealthCheckPath = "backend.healthcheck.path" SuffixBackendHealthCheckPath = "backend.healthcheck.path"
SuffixBackendHealthCheckPort = "backend.healthcheck.port" SuffixBackendHealthCheckPort = "backend.healthcheck.port"
SuffixBackendHealthCheckInterval = "backend.healthcheck.interval" SuffixBackendHealthCheckInterval = "backend.healthcheck.interval"
@ -83,6 +84,7 @@ const (
TraefikBackendID = Prefix + SuffixBackendID TraefikBackendID = Prefix + SuffixBackendID
TraefikBackendCircuitBreaker = Prefix + SuffixBackendCircuitBreaker TraefikBackendCircuitBreaker = Prefix + SuffixBackendCircuitBreaker
TraefikBackendCircuitBreakerExpression = Prefix + SuffixBackendCircuitBreakerExpression TraefikBackendCircuitBreakerExpression = Prefix + SuffixBackendCircuitBreakerExpression
TraefikBackendHealthCheckScheme = Prefix + SuffixBackendHealthCheckScheme
TraefikBackendHealthCheckPath = Prefix + SuffixBackendHealthCheckPath TraefikBackendHealthCheckPath = Prefix + SuffixBackendHealthCheckPath
TraefikBackendHealthCheckPort = Prefix + SuffixBackendHealthCheckPort TraefikBackendHealthCheckPort = Prefix + SuffixBackendHealthCheckPort
TraefikBackendHealthCheckInterval = Prefix + SuffixBackendHealthCheckInterval TraefikBackendHealthCheckInterval = Prefix + SuffixBackendHealthCheckInterval

View file

@ -235,17 +235,19 @@ func GetHealthCheck(labels map[string]string) *types.HealthCheck {
return nil return nil
} }
scheme := GetStringValue(labels, TraefikBackendHealthCheckScheme, "")
port := GetIntValue(labels, TraefikBackendHealthCheckPort, DefaultBackendHealthCheckPort) port := GetIntValue(labels, TraefikBackendHealthCheckPort, DefaultBackendHealthCheckPort)
interval := GetStringValue(labels, TraefikBackendHealthCheckInterval, "") interval := GetStringValue(labels, TraefikBackendHealthCheckInterval, "")
hostname := GetStringValue(labels, TraefikBackendHealthCheckHostname, "") hostname := GetStringValue(labels, TraefikBackendHealthCheckHostname, "")
headers := GetMapValue(labels, TraefikBackendHealthCheckHeaders) headers := GetMapValue(labels, TraefikBackendHealthCheckHeaders)
return &types.HealthCheck{ return &types.HealthCheck{
Hostname: hostname, Scheme: scheme,
Headers: headers,
Path: path, Path: path,
Port: port, Port: port,
Interval: interval, Interval: interval,
Hostname: hostname,
Headers: headers,
} }
} }

View file

@ -371,11 +371,20 @@ func TestGetHealthCheck(t *testing.T) {
TraefikBackendHealthCheckPath: "/health", TraefikBackendHealthCheckPath: "/health",
TraefikBackendHealthCheckPort: "80", TraefikBackendHealthCheckPort: "80",
TraefikBackendHealthCheckInterval: "6", TraefikBackendHealthCheckInterval: "6",
TraefikBackendHealthCheckHeaders: "Foo:bar || Goo:bir",
TraefikBackendHealthCheckHostname: "traefik",
TraefikBackendHealthCheckScheme: "http",
}, },
expected: &types.HealthCheck{ expected: &types.HealthCheck{
Scheme: "http",
Path: "/health", Path: "/health",
Port: 80, Port: 80,
Interval: "6", Interval: "6",
Hostname: "traefik",
Headers: map[string]string{
"Foo": "bar",
"Goo": "bir",
},
}, },
}, },
} }

View file

@ -173,6 +173,7 @@ func TestBuildConfiguration(t *testing.T) {
withLabel(label.TraefikBackend, "foobar"), withLabel(label.TraefikBackend, "foobar"),
withLabel(label.TraefikBackendCircuitBreakerExpression, "NetworkErrorRatio() > 0.5"), withLabel(label.TraefikBackendCircuitBreakerExpression, "NetworkErrorRatio() > 0.5"),
withLabel(label.TraefikBackendHealthCheckScheme, "http"),
withLabel(label.TraefikBackendHealthCheckPath, "/health"), withLabel(label.TraefikBackendHealthCheckPath, "/health"),
withLabel(label.TraefikBackendHealthCheckPort, "880"), withLabel(label.TraefikBackendHealthCheckPort, "880"),
withLabel(label.TraefikBackendHealthCheckInterval, "6"), withLabel(label.TraefikBackendHealthCheckInterval, "6"),
@ -367,6 +368,7 @@ func TestBuildConfiguration(t *testing.T) {
ExtractorFunc: "client.ip", ExtractorFunc: "client.ip",
}, },
HealthCheck: &types.HealthCheck{ HealthCheck: &types.HealthCheck{
Scheme: "http",
Path: "/health", Path: "/health",
Port: 880, Port: 880,
Interval: "6", Interval: "6",

View file

@ -123,6 +123,7 @@ func TestBuildConfiguration(t *testing.T) {
withLabel(label.TraefikBackend, "foobar"), withLabel(label.TraefikBackend, "foobar"),
withLabel(label.TraefikBackendCircuitBreakerExpression, "NetworkErrorRatio() > 0.5"), withLabel(label.TraefikBackendCircuitBreakerExpression, "NetworkErrorRatio() > 0.5"),
withLabel(label.TraefikBackendHealthCheckScheme, "http"),
withLabel(label.TraefikBackendHealthCheckPath, "/health"), withLabel(label.TraefikBackendHealthCheckPath, "/health"),
withLabel(label.TraefikBackendHealthCheckPort, "880"), withLabel(label.TraefikBackendHealthCheckPort, "880"),
withLabel(label.TraefikBackendHealthCheckInterval, "6"), withLabel(label.TraefikBackendHealthCheckInterval, "6"),
@ -318,6 +319,7 @@ func TestBuildConfiguration(t *testing.T) {
ExtractorFunc: "client.ip", ExtractorFunc: "client.ip",
}, },
HealthCheck: &types.HealthCheck{ HealthCheck: &types.HealthCheck{
Scheme: "http",
Path: "/health", Path: "/health",
Port: 880, Port: 880,
Interval: "6", Interval: "6",

View file

@ -41,6 +41,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
label.TraefikBackend: "foobar", label.TraefikBackend: "foobar",
label.TraefikBackendCircuitBreakerExpression: "NetworkErrorRatio() > 0.5", label.TraefikBackendCircuitBreakerExpression: "NetworkErrorRatio() > 0.5",
label.TraefikBackendHealthCheckScheme: "http",
label.TraefikBackendHealthCheckPath: "/health", label.TraefikBackendHealthCheckPath: "/health",
label.TraefikBackendHealthCheckPort: "880", label.TraefikBackendHealthCheckPort: "880",
label.TraefikBackendHealthCheckInterval: "6", label.TraefikBackendHealthCheckInterval: "6",
@ -241,6 +242,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
ExtractorFunc: "client.ip", ExtractorFunc: "client.ip",
}, },
HealthCheck: &types.HealthCheck{ HealthCheck: &types.HealthCheck{
Scheme: "http",
Path: "/health", Path: "/health",
Port: 880, Port: 880,
Interval: "6", Interval: "6",

View file

@ -1335,21 +1335,22 @@ func parseHealthCheckOptions(lb healthcheck.LoadBalancer, backend string, hc *ty
intervalOverride, err := time.ParseDuration(hc.Interval) intervalOverride, err := time.ParseDuration(hc.Interval)
switch { switch {
case err != nil: case err != nil:
log.Errorf("Illegal healthcheck interval for backend '%s': %s", backend, err) log.Errorf("Illegal health check interval for backend '%s': %s", backend, err)
case intervalOverride <= 0: case intervalOverride <= 0:
log.Errorf("Healthcheck interval smaller than zero for backend '%s', backend", backend) log.Errorf("Health check interval smaller than zero for backend '%s', backend", backend)
default: default:
interval = intervalOverride interval = intervalOverride
} }
} }
return &healthcheck.Options{ return &healthcheck.Options{
Hostname: hc.Hostname, Scheme: hc.Scheme,
Headers: hc.Headers,
Path: hc.Path, Path: hc.Path,
Port: hc.Port, Port: hc.Port,
Interval: interval, Interval: interval,
LB: lb, LB: lb,
Hostname: hc.Hostname,
Headers: hc.Headers,
} }
} }

View file

@ -29,6 +29,7 @@
{{ $healthCheck := getHealthCheck $service.TraefikLabels }} {{ $healthCheck := getHealthCheck $service.TraefikLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."backend-{{ $backendName }}".healthCheck] [backends."backend-{{ $backendName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"

View file

@ -30,6 +30,7 @@
{{ $healthCheck := getHealthCheck $backend.SegmentLabels }} {{ $healthCheck := getHealthCheck $backend.SegmentLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."backend-{{ $backendName }}".healthCheck] [backends."backend-{{ $backendName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"

View file

@ -29,6 +29,7 @@
{{ $healthCheck := getHealthCheck $firstInstance.TraefikLabels }} {{ $healthCheck := getHealthCheck $firstInstance.TraefikLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."backend-{{ $serviceName }}".healthCheck] [backends."backend-{{ $serviceName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"

View file

@ -29,6 +29,7 @@
{{ $healthCheck := getHealthCheck $backend }} {{ $healthCheck := getHealthCheck $backend }}
{{if $healthCheck }} {{if $healthCheck }}
[backends.{{ $backendName }}.healthCheck] [backends.{{ $backendName }}.healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"

View file

@ -32,6 +32,7 @@
{{ $healthCheck := getHealthCheck $app.SegmentLabels }} {{ $healthCheck := getHealthCheck $app.SegmentLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."{{ $backendName }}".healthCheck] [backends."{{ $backendName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"

View file

@ -32,6 +32,7 @@
{{ $healthCheck := getHealthCheck $app.TraefikLabels }} {{ $healthCheck := getHealthCheck $app.TraefikLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."backend-{{ $backendName }}".healthCheck] [backends."backend-{{ $backendName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"

View file

@ -31,6 +31,7 @@
{{ $healthCheck := getHealthCheck $backend.SegmentLabels }} {{ $healthCheck := getHealthCheck $backend.SegmentLabels }}
{{if $healthCheck }} {{if $healthCheck }}
[backends."backend-{{ $backendName }}".healthCheck] [backends."backend-{{ $backendName }}".healthCheck]
scheme = "{{ $healthCheck.Scheme }}"
path = "{{ $healthCheck.Path }}" path = "{{ $healthCheck.Path }}"
port = {{ $healthCheck.Port }} port = {{ $healthCheck.Port }}
interval = "{{ $healthCheck.Interval }}" interval = "{{ $healthCheck.Interval }}"

View file

@ -69,11 +69,12 @@ type WhiteList struct {
// HealthCheck holds HealthCheck configuration // HealthCheck holds HealthCheck configuration
type HealthCheck struct { type HealthCheck struct {
Headers map[string]string `json:"headers,omitempty"` Scheme string `json:"scheme,omitempty"`
Hostname string `json:"hostname,omitempty"`
Path string `json:"path,omitempty"` Path string `json:"path,omitempty"`
Port int `json:"port,omitempty"` Port int `json:"port,omitempty"`
Interval string `json:"interval,omitempty"` Interval string `json:"interval,omitempty"`
Hostname string `json:"hostname,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
} }
// Server holds server configuration. // Server holds server configuration.