I obtained a wildcard certificate to be applied within Traefik. The files are:
ChainCA1.crt
ChainCA2.crt
RootCA.crt
domain.key
domain.pem
For this example, we will configure our Traefik with the following requirements:
- Use subdomain.
- Implement TLS.
- Redirect HTTP to HTTPS.
- Accessible via the subdirectory path
/traefik
- Implement Basic Auth.
We are using a combination of static configuration using labels
and dynamic configuration using traefik.yml
for the service.
Dynamic configuration is necessary because Traefik can only read certificates from it.
You can generate the HASHED_PASSWORD
using this command, and don’t forget to escape $
into $$
from the output before putting it in the .env
file:
After everything is set up, simply run docker compose up -d
.
Now, the moment of truth arrives as we open the URL https://subdomain.example.com
… and encounter an error:
Unable to verify the first certificate
The logs appear as follows:
Time for debugging, we can use run this command:
Oops! It seems the CA chain was not properly set up!
After some investigation, it turns out that domain.pem
is the culprit. It doesn’t contain the rest of the .crt
files.
To fix this, we only need to merge the content of these files into domain.pem
:
ChainCA1.crt
ChainCA2.crt
RootCA.crt
After restarting Traefik and using the same command, we get the following:
Yes, now our browser URL bar is green 🟢.