Consul Catalog Provider
Traefik can be configured to use service discovery catalog of Consul as a provider.
################################################################
# Consul Catalog Provider
################################################################
# Enable Consul Catalog Provider.
[consulCatalog]
# Consul server endpoint.
#
# Required
# Default: "127.0.0.1:8500"
#
endpoint = "127.0.0.1:8500"
# Expose Consul catalog services by default in Traefik.
#
# Optional
# Default: true
#
exposedByDefault = false
# Allow Consul server to serve the catalog reads regardless of whether it is the leader.
#
# Optional
# Default: false
#
stale = false
# Default base domain used for the frontend rules.
#
# Optional
#
domain = "consul.localhost"
# Keep a Consul node only if all checks status are passing
# If true, only the Consul nodes with checks status 'passing' will be kept.
# if false, only the Consul nodes with checks status 'passing' or 'warning' will be kept.
#
# Optional
# Default: true
#
strictChecks = true
# Prefix for Consul catalog tags.
#
# Optional
# Default: "traefik"
#
prefix = "traefik"
# Default frontEnd Rule for Consul services.
#
# The format is a Go Template with:
# - ".ServiceName", ".Domain" and ".Attributes" available
# - "getTag(name, tags, defaultValue)", "hasTag(name, tags)" and "getAttribute(name, tags, defaultValue)" functions are available
# - "getAttribute(...)" function uses prefixed tag names based on "prefix" value
#
# Optional
# Default: "Host:{{.ServiceName}}.{{.Domain}}"
#
#frontEndRule = "Host:{{.ServiceName}}.{{.Domain}}"
# Enable Consul catalog TLS connection.
#
# Optional
#
# [consulCatalog.tls]
# ca = "/etc/ssl/ca.crt"
# cert = "/etc/ssl/consul.crt"
# key = "/etc/ssl/consul.key"
# insecureSkipVerify = true
# Override default configuration template.
# For advanced users :)
#
# Optional
#
# filename = "consulcatalog.tmpl"
# Override template version
# For advanced users :)
#
# Optional
# - "1": previous template version (must be used only with older custom templates, see "filename")
# - "2": current template version (must be used to force template version when "filename" is used)
#
# templateVersion = 2
This provider will create routes matching on hostname based on the service name used in Consul.
To enable constraints see provider-specific constraints section.
Tags
Additional settings can be defined using Consul Catalog tags.
Note
The default prefix is traefik
.
Label | Description |
---|---|
| Disables this container in Traefik. |
| Overrides the default http protocol. |
| Assigns this weight to the container. |
traefik.backend.buffering.maxRequestBodyBytes=0 | See buffering section. |
traefik.backend.buffering.maxResponseBodyBytes=0 | See buffering section. |
traefik.backend.buffering.memRequestBodyBytes=0 | See buffering section. |
traefik.backend.buffering.memResponseBodyBytes=0 | See buffering section. |
traefik.backend.buffering.retryExpression=EXPR | See buffering section. |
| Creates a circuit breaker to be used against the backend. ex: NetworkErrorRatio() > 0. |
| Defines the interval between two flushes when forwarding response from backend to client. |
| Enables health check for the backend, hitting the container at path . |
| Defines the health check interval. |
| Sets a different port for the health check. |
traefik.backend.healthcheck.scheme=http | Overrides the server URL scheme. |
| Defines the health check hostname. |
| Defines the health check request headers
Format: HEADER:value||HEADER2:value2 |
| Overrides the default wrr load balancer algorithm. |
| Enables backend sticky sessions. |
| Sets the cookie name manually for sticky sessions. |
| Sets secure cookie option for sticky sessions. |
| Sets http only cookie option for sticky sessions. |
| Sets same site cookie option for sticky sessions. (none , lax , strict ) |
| Enables backend sticky sessions. (DEPRECATED) |
| Sets a maximum number of connections to the backend. Must be used in conjunction with the below label to take effect. |
| Sets the function to be used against the request to determine what to limit maximum connections to the backend by. Must be used in conjunction with the above label to take effect. |
| Sets basic authentication to this frontend in CSV format: User:Hash,User:Hash (DEPRECATED). |
| If set to true , removes the Authorization header. |
| Sets basic authentication to this frontend in CSV format: User:Hash,User:Hash . |
| Sets basic authentication with an external file; if users and usersFile are provided, both are merged, with external file contents having precedence. |
| If set to true , removes the Authorization header. |
| Sets digest authentication to this frontend in CSV format: User:Realm:Hash,User:Realm:Hash . |
| Sets digest authentication with an external file; if users and usersFile are provided, both are merged, with external file contents having precedence. |
| Sets the URL of the authentication server. |
| Sets the forward authentication authResponseHeaders in CSV format: X-Auth-User,X-Auth-Header |
| Sets the Certificate Authority (CA) for the TLS connection with the authentication server. |
| Checks the certificates if present but do not force to be signed by a specified Certificate Authority (CA). |
| Sets the Certificate for the TLS connection with the authentication server. |
| If set to true invalid SSL certificates are accepted. |
| Sets the Certificate for the TLS connection with the authentication server. |
| Trusts X-Forwarded- headers. |
| Sets the header used to pass the authenticated user to the application. |
| Assigns this frontend to entry points http and https .
Overrides defaultEntryPoints |
| See custom error pages section. |
| See custom error pages section. |
| See custom error pages section. |
| Forwards client Host header to the backend. |
| Add the issuer.commonName field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the issuer.country field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the issuer.domainComponent field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the issuer.locality field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the issuer.organization field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the issuer.province field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the subject.serialNumber field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the noAfter field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the noBefore field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the sans field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the subject.commonName field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the subject.country field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the subject.domainComponent field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the subject.locality field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the subject.organization field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the subject.province field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Add the subject.serialNumber field in a escaped client infos in the X-Forwarded-Ssl-Client-Cert-Infos header. |
| Pass the escaped pem in the X-Forwarded-Ssl-Client-Cert header. |
| Forwards TLS Client certificates to the backend. |
| Overrides default frontend priority. |
| See rate limiting section. |
| See rate limiting section. |
| See rate limiting section. |
| See rate limiting section. |
| Enables Redirect to another entryPoint to this frontend (e.g. HTTPS). |
| Redirects to another URL to this frontend.
Must be set with traefik.frontend.redirect.replacement . |
| Redirects to another URL to this frontend.
Must be set with traefik.frontend.redirect.regex . |
| Returns 301 instead of 302. |
| Overrides the default frontend rule. Default: Host:{{.ServiceName}}.{{.Domain}} . |
| Sets a list of IP-Ranges which are allowed to access. An unset or empty list allows all Source-IPs to access. If one of the Net-Specifications are invalid, the whole list is invalid and allows all Source-IPs to access. |
| Uses X-Forwarded-For header as valid source of IP for the white list. |
Multiple frontends for a single service
If you need to support multiple frontends for a service, for example when having multiple rules
that can't be combined, specify them as follows:
<prefix>.frontends.A.rule=Host:A:PathPrefix:/A
<prefix>.frontends.B.rule=Host:B:PathPrefix:/
A
and B
here are just arbitrary names, they can be anything. You can use any setting that applies to
from the table above.
Custom Headers
Note
The default prefix is traefik
.
Label | Description |
---|---|
| Provides the container with custom request headers that will be appended to each request forwarded to the container.
Format: HEADER:value||HEADER2:value2 |
| Appends the headers to each response returned by the container, before forwarding the response to the client.
Format: HEADER:value||HEADER2:value2 |
Security Headers
Note
The default prefix is traefik
.
Label | Description |
---|---|
| Provides a list of allowed hosts that requests will be processed.
Format: Host1,Host2 |
| Adds the X-XSS-Protection header with the value 1; mode=block . |
| Adds CSP Header with the custom value. |
| Adds the X-Content-Type-Options header with the value nosniff . |
| Set custom value for X-XSS-Protection header. This overrides the BrowserXssFilter option. |
| Overrides the X-Frame-Options header with the custom value. |
| Adds the STS header to non-SSL requests. |
| Adds the X-Frame-Options header with the value of DENY . |
| Provides a list of headers that the proxied hostname may be stored.
Format: HEADER1,HEADER2 |
| This will cause the AllowedHosts , SSLRedirect , and STSSeconds /STSIncludeSubdomains options to be ignored during development.
When deploying to production, be sure to set this to false. |
| Adds HPKP header. |
| Adds referrer policy header. |
| Forces the frontend to redirect to SSL if a non-SSL request is sent. |
| Forces the frontend to redirect to SSL if a non-SSL request is sent, but by sending a 302 instead of a 301. |
| This setting configures the hostname that redirects will be based on. Default is "", which is the same host as the request. |
| If SSLForceHost is true and SSLHost is set, requests will be forced to use SSLHost even the ones that are already using SSL. Default is false. |
| Header combinations that would signify a proper SSL Request (Such as X-Forwarded-Proto:https ).
Format: HEADER:value||HEADER2:value2 |
| Sets the max-age of the STS header. |
| Adds the IncludeSubdomains section of the STS header. |
| Adds the preload flag to the STS header. |
Examples
If you want that Traefik uses Consul tags correctly you need to defined them like that:
traefik.enable=true
traefik.tags=api
traefik.tags=external
If the prefix defined in Traefik configuration is bla
, tags need to be defined like that:
bla.enable=true
bla.tags=api
bla.tags=external