Noob a Traefik y Docker. He preparado un certificado autofirmado usando:
openssl req -x509 -newkey rsa:4096 -keyout www.example.co.uk.key -out www.example.co.uk.crt-days 365
En mi archivo traefik.toml tengo:
[entryPoints] [entryPoints.http] address = ":80" [entryPoints.https] address = ":443" [entryPoints.https.tls] [[entryPoints.https.tls.certificates]] certFile = "certs/www.example.co.uk.crt" keyFile = "certs/www.example.co.uk.key"
Sin embargo, esto da como resultado:
traefik | time="2019-06-17T22:11:17Z" level=debug msg="Serving default cert for request: \"www.example.co.uk\"" traefik | time="2019-06-17T22:11:17Z" level=debug msg="http: TLS handshake error from 172.20.0.1:57770: tls: no certificates configured"
Si omito las definiciones de certificado para que traefik.toml se lea como:
[entryPoints] [entryPoints.http] address = ":80" [entryPoints.https] address = ":443" [entryPoints.https.tls] # [[entryPoints.https.tls.certificates]] # certFile = "certs/www.example.co.uk.crt" # keyFile = "certs/www.example.co.uk.key"
Obtuve el certificado ficticio proporcionado por Traefik y funciona muy bien, pero solo quiero entender por qué no se usan mis certificados definidos.
En mi docker-compose.yml creo que he montado el volumen correcto:
volumes: - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events - ./traefik.toml:/traefik.toml - /var/www/docker/certs:/certs
Y los certificados residen en certs/
en relación con mis archivos docker-compose.ym
l y traefik.toml
. Los permisos también parecen buenos, ambos propiedad de root: el crt
tiene 644 y key
tiene 600.
¿Cómo puedo usar un certificado autofirmado en lugar de los valores predeterminados de Traefiks?
Probablemente un desajuste de ruta, particularmente con algunas rutas relativas y otras absolutas. Pruebe lo siguiente en su archivo de redacción (ruta relativa a los certificados locales):
volumes: - /var/run/docker.sock:/var/run/docker.sock - ./traefik.toml:/traefik.toml - ./certs:/certs
Y luego cambie a una ruta absoluta en el toml (barra inclinada inicial en certificados):
[entryPoints] [entryPoints.http] address = ":80" [entryPoints.https] address = ":443" [entryPoints.https.tls] [[entryPoints.https.tls.certificates]] certFile = "/certs/www.example.co.uk.crt" keyFile = "/certs/www.example.co.uk.key"