Search code examples
dockerdocker-composetraefik

Traefik 2.2 with docker-compose configuration TLS


I've been trying to find a simple overview of how to enable SSL on a website with Traefik. All the examples are for the .toml file though, and I want to configure it using my docker-compose file.

The only sort of example I've found in the Traefik docs is this: https://docs.traefik.io/reference/dynamic-configuration/docker/

How can I convert the following config to a docker-compose setting?

[[tls.certificates]]
  certFile = "/path/to/domain.cert"
  keyFile = "/path/to/domain.key"

Solution

  • Actually, you can't do this. Certificates definition is only supported through file provider. Quote from docs:

    In the above example, we've used the file provider to handle these definitions. It is the only available method to configure the certificates (as well as the options and the stores). However, in Kubernetes, the certificates can and must be provided by secrets.

    See here: https://docs.traefik.io/https/tls/#user-defined