Traefik & Consul

Configuration Example

You can enable the Consul provider as detailed below:

File (YAML)

  1. providers:
  2. consul: {}

File (TOML)

  1. [providers.consul]

CLI

  1. --providers.consul=true

Configuration Options

FieldDescriptionDefaultRequired
providers.providersThrottleDurationMinimum amount of time to wait for, after a configuration reload, before taking into account any new configuration refresh event.
If multiple events occur within this time, only the most recent one is taken into account, and all others are discarded.
This option cannot be set per provider, but the throttling algorithm applies to each of them independently.
2sNo
providers.consul.endpointsDefines the endpoint to access Consul.“127.0.0.1:8500”yes
providers.consul.rootKeyDefines the root key of the configuration.“traefik”yes
providers.consul.namespacesDefines the namespaces to query. See here for more information“”no
providers.consul.usernameDefines a username to connect to Consul with.“”no
providers.consul.passwordDefines a password with which to connect to Consul.“”no
providers.consul.tokenDefines a token with which to connect to Consul.“”no
providers.consul.tlsDefines the TLS configuration used for the secure connection to Consul-No
providers.consul.tls.caDefines the path to the certificate authority used for the secure connection to Consul, it defaults to the system bundle.-Yes
providers.consul.tls.certDefines the path to the public certificate used for the secure connection to Consul. When using this option, setting the key option is required.-Yes
providers.consul.tls.keyDefines the path to the private key used for the secure connection to Consul. When using this option, setting the cert option is required.-Yes
providers.consul.tls.insecureSkipVerifyInstructs the provider to accept any certificate presented by Consul when establishing a TLS connection, regardless of the hostnames the certificate covers.falseNo

namespaces

The namespaces option defines the namespaces to query. When using the namespaces option, the discovered configuration object names will be suffixed as shown below:

  1. <resource-name>@consul-<namespace>

Warning

The namespaces option only works with Consul Enterprise, which provides the Namespaces feature.

Warning

One should only define either the namespaces option or the namespace option.

File (YAML)

  1. providers:
  2. consul:
  3. namespaces:
  4. - "ns1"
  5. - "ns2"
  6. # ...

File (TOML)

  1. [providers.consul]
  2. namespaces = ["ns1", "ns2"]
  3. # ...

CLI

  1. --providers.consul.namespaces=ns1,ns2
  2. # ...

Routing Configuration

See the dedicated section in routing.