Should my Docker websites share a certificate when I use Traefik?

November 16, 2026 5 answers
Asked by Neravi.4t

I have multiple websites in Docker containers behind Traefik. Apache asks for a certificate and key when I configure HTTPS. Should I copy the same files into every container, or make a separate pair for each site?

Answers

3n!velvetpiston_852

You can terminate TLS at Traefik and have it forward requests to Apache over HTTP on the Docker network. In that setup, Apache doesn't need a certificate at all. Traefik needs a certificate covering each public hostname, either through separate certificates or a certificate covering multiple names.

That does leave the traffic between Traefik and Apache unencrypted, so decide whether that's acceptable for your network. If you need encryption on that hop too, configure HTTPS on the backend as well.

Neravi.4t:

So the browser connects to Traefik over HTTPS, even though Apache itself is serving HTTP?

_z62!clayfunnel.5:

Right. Traefik handles the browser's TLS connection, then makes a separate HTTP connection to Apache.

Reply to this answer
7e+gasketacorn_358

One certificate can cover several sites, but it has to match their hostnames. You can use a certificate with the names listed as subject alternative names, or a wildcard certificate for matching subdomains. A certificate for one hostname doesn't automatically cover all the others.

Separate certificates are fine too. The choice isn't really about how many containers you have, it's about which hostnames the certificates cover and where TLS terminates.

Reply to this answer
_g65!pixelgrommet.8

For public sites, letting Traefik obtain certificates from Let's Encrypt can save you from distributing certificate files by hand. A DNS challenge is an option, including for wildcard certificates. You still need to configure the challenge and certificate resolver for your setup.

A self-signed certificate generated with OpenSSL will normally produce browser warnings. For local development, mkcert is another option if you install its local trust authority on the clients that need to trust it.

Reply to this answer
Lumi

If you're supplying your own certificate files to Traefik, mount them into the container rather than baking them into the image. That keeps certificate storage separate from container rebuilds and gives you a cleaner way to replace the files when they rotate. Make sure the private key is protected and only exposed where it's needed.

Reply to this answer
_f39+teacrate.7

First check which proxy actually receives the HTTPS connection. If Apache is public-facing in front of Traefik or the other containers, you could terminate TLS there instead. The certificate belongs at the component handling that connection, not automatically in every website container.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions