Traefik & Consul

A Story of KV store & Containers

Store your configuration in Consul and let Traefik do the rest!

Routing Configuration

See the dedicated section in routing.

Provider Configuration

endpoints

Required, Default=”127.0.0.1:8500”

Defines how to access Consul.

File (YAML)

  1. providers:
  2. consul:
  3. endpoints:
  4. - "127.0.0.1:8500"

File (TOML)

  1. [providers.consul]
  2. endpoints = ["127.0.0.1:8500"]

CLI

  1. --providers.consul.endpoints=127.0.0.1:8500

rootKey

Required, Default=”traefik”

Defines the root key of the configuration.

File (YAML)

  1. providers:
  2. consul:
  3. rootKey: "traefik"

File (TOML)

  1. [providers.consul]
  2. rootKey = "traefik"

CLI

  1. --providers.consul.rootkey=traefik

namespace

Deprecated in favor of the namespaces option.

Optional, Default=””

The namespace option defines the namespace to query.

Warning

The namespace 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. # ...
  4. namespace: "production"

File (TOML)

  1. [providers.consul]
  2. # ...
  3. namespace = "production"

CLI

  1. --providers.consul.namespace=production

namespaces

Optional, Default=””

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. # ...

username

Optional, Default=””

Defines a username to connect to Consul with.

File (YAML)

  1. providers:
  2. consul:
  3. # ...
  4. username: "foo"

File (TOML)

  1. [providers.consul]
  2. # ...
  3. username = "foo"

CLI

  1. --providers.consul.username=foo

password

Optional, Default=””

Defines a password with which to connect to Consul.

File (YAML)

  1. providers:
  2. consul:
  3. # ...
  4. password: "bar"

File (TOML)

  1. [providers.consul]
  2. # ...
  3. password = "bar"

CLI

  1. --providers.consul.password=bar

token

Optional, Default=””

Defines a token with which to connect to Consul.

File (YAML)

  1. providers:
  2. consul:
  3. # ...
  4. token: "bar"

File (TOML)

  1. [providers.consul]
  2. # ...
  3. token = "bar"

CLI

  1. --providers.consul.token=bar

tls

Optional

Defines the TLS configuration used for the secure connection to Consul.

ca

Optional

ca is the path to the certificate authority used for the secure connection to Consul, it defaults to the system bundle.

File (YAML)

  1. providers:
  2. consul:
  3. tls:
  4. ca: path/to/ca.crt

File (TOML)

  1. [providers.consul.tls]
  2. ca = "path/to/ca.crt"

CLI

  1. --providers.consul.tls.ca=path/to/ca.crt

cert

Optional

cert is the path to the public certificate used for the secure connection to Consul. When using this option, setting the key option is required.

File (YAML)

  1. providers:
  2. consul:
  3. tls:
  4. cert: path/to/foo.cert
  5. key: path/to/foo.key

File (TOML)

  1. [providers.consul.tls]
  2. cert = "path/to/foo.cert"
  3. key = "path/to/foo.key"

CLI

  1. --providers.consul.tls.cert=path/to/foo.cert
  2. --providers.consul.tls.key=path/to/foo.key

key

Optional

key is the path to the private key used for the secure connection to Consul. When using this option, setting the cert option is required.

File (YAML)

  1. providers:
  2. consul:
  3. tls:
  4. cert: path/to/foo.cert
  5. key: path/to/foo.key

File (TOML)

  1. [providers.consul.tls]
  2. cert = "path/to/foo.cert"
  3. key = "path/to/foo.key"

CLI

  1. --providers.consul.tls.cert=path/to/foo.cert
  2. --providers.consul.tls.key=path/to/foo.key

insecureSkipVerify

Optional, Default=false

If insecureSkipVerify is true, the TLS connection to Consul accepts any certificate presented by the server regardless of the hostnames it covers.

File (YAML)

  1. providers:
  2. consul:
  3. tls:
  4. insecureSkipVerify: true

File (TOML)

  1. [providers.consul.tls]
  2. insecureSkipVerify = true

CLI

  1. --providers.consul.tls.insecureSkipVerify=true