Hi,
I try to get traefik v2 working with docker swarm with TLS-ALPN challenge in order to get certificates from let’s encrypt.
I have already tested like 20 differents configuration without manage to get certificates from tls ACME and dont understand why. I don’t think this is a problem about my traefik config but rather the network configuration because I’m not sure that let’s encrypt manage to connect through http://fqdn:443/ to get the information of the default certificate
I have already tested the httpChallenge but get an error too. I want to understand my errors on tls and http challenge so I think, I will create another post for my http challenge error.
ok let’s started:
I have a swarm cluster of three nodes with one traefik on each node and I have an OVH loadbalancer in frontend.
First of all: My entrypoint in my netowrk is ovh through load balancer
Front-end overview
Name
lb-frontend-443
Protocol
tcp
Port
443
Name
lb-frontend-80
Protocol
http
Port
80
Secondly: My frontend sends requests to farm servers which contains the three nodes docker
Name
farm-443
Protocol
tcp
Port
443
Datacentre
Distribution mode
Round-robin
Track session
Source IP
Probe
TCP
Port
443
Name
farm-80
Protocol
http
Port
80
Datacentre
Distribution mode
Source
Track session
Source IP
Probe
TCP
Port
80
Then, I have deployed on these servers traefik with port 80 and 443 bind to the host
I manage to connect to traefik dashboard
This is my docker-compose:
version: '3.7'
networks:
traefik-public:
external: true
services:
traefik:
image: traefik:v2.2
hostname: "{{.Node.Hostname}}-{{.Service.Name}}"
command:
- '--configFile=/etc/traefik/traefik.toml'
networks:
- traefik-public
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /traefik.toml:/etc/traefik/traefik.toml
- /certificate:/certificate
deploy:
mode: global
restart_policy:
condition: on-failure
labels:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.http.routers.traefik-router.rule=Host(`traefik.${DOMAIN}`)
- traefik.http.routers.traefik-router.entrypoints=websecure
- traefik.http.routers.traefik-router.tls=true
- traefik.http.routers.traefik-router.tls.certresolver=letsencrypt
- traefik.http.routers.traefik-router.service=api@internal
- traefik.http.middlewares.default-compress.compress=true
- traefik.http.middlewares.default-https.chain.middlewares=default-compress
- traefik.http.routers.traefik-router.middlewares=traefik-auth
- traefik.http.middlewares.traefik-auth.basicauth.users=${ADMIN_USER?Variable ADMIN_USER not set}:${HASHED_PASSWORD?Variable HASHED_PASSWORD not set}
- traefik.http.services.traefik-services.loadbalancer.server.port=8080
This is my conf.toml
################################################################
# Global configuration
################################################################
[global]
checkNewVersion = true
sendAnonymousUsage = false
################################################################
# Entrypoints configuration
################################################################
# Entrypoints definition
#
# Optional
# Default:
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web.http]
[entryPoints.web.http.redirections]
[entryPoints.web.http.redirections.entryPoint]
to = "websecure"
scheme = "https"
permanent = true
[entryPoints.websecure]
address = ":443"
[entryPoints.websecure.http.tls]
certResolver = "letsencrypt"
################################################################
# Traefik logs configuration
################################################################
[log]
level = "DEBUG"
format = "json"
################################################################
# API and dashboard configuration
################################################################
[api]
insecure = false
dashboard = true
################################################################
# ACME configuration
################################################################
[certificatesResolvers.letsencrypt.acme]
#caServer = "https://acme-v02.api.letsencrypt.org/directory"
caServer = "https://acme-staging-v02.api.letsencrypt.org/directory"
email = "${EMAIL}"
storage = "/certificate/acme/acme.json"
[certificatesResolvers.letsencrypt.acme.tlsChallenge]
#[certificatesResolvers.letsencrypt.acme.httpChallenge]
# entryPoint = "web"
################################################################
# Docker configuration backend
################################################################
# Enable Docker configuration backend
[providers.docker]
endpoint = "unix:///var/run/docker.sock"
swarmMode = true
network = "traefik-public"
watch = true
exposedByDefault = false
I’m not sure about the label - traefik.http.services.traefik-services.loadbalancer.server.port=443
. I’m not sure about the connection of let’s encrypt. I guess, the let’s encrypt server will connect to my 443 host port of swarm server and will be bind to traefik port with 443:443.
This is my traefik logs:
{"level":"debug","msg":"legolog: [INFO] [traefik.demo.cloud.patrowl.io] acme: Trying to solve TLS-ALPN-01","time":"2020-04-07T17:34:25Z"}
{"level":"debug","msg":"TLS Challenge CleanUp temp certificate for traefik.demo.cloud.patrowl.io","providerName":"acme","time":"2020-04-07T17:34:29Z"}
{"level":"debug","msg":"legolog: [INFO] Deactivating auth: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/47989242","time":"2020-04-07T17:34:29Z"}
{"level":"debug","msg":"legolog: [INFO] Unable to deactivate the authorization: https://acme-staging-v02.api.letsencrypt.org/acme/authz-v3/47989242","time":"2020-04-07T17:34:29Z"}
{"level":"error","msg":"Unable to obtain ACME certificate for domains \"traefik.demo.cloud.patrowl.io\": unable to generate a certificate for the domains [traefik.demo.cloud.patrowl.io]: acme: Error -\u003e One or more domains had a problem:\n[traefik.demo.cloud.patrowl.io] acme: error: 403 :: urn:ietf:params:acme:error:unauthorized :: During secondary validation: Incorrect validation certificate for tls-alpn-01 challenge. Requested traefik.demo.cloud.patrowl.io from 51.91.60.234:443. Received 1 certificate(s), first certificate had names \"ec5552cec6a19446c4eaf94ddd866262.82c4629185c6e4458ce087bec5fef363.traefik.default, traefik default cert\", url: \n","providerName":"letsencrypt.acme","routerName":"traefik-router@docker","rule":"Host(`traefik.demo.cloud.patrowl.io`)","time":"2020-04-07T17:34:29Z"}
{"level":"debug","msg":"Serving default certificate for request: \"traefik.demo.cloud.patrowl.io\"","time":"2020-04-07T17:34:30Z"}
{"level":"debug","msg":"http: TLS handshake error from 10.0.0.2:21000: remote error: tls: bad certificate","time":"2020-04-07T17:34:30Z"}
I tried to find some issues on let’s encrypt forum but didnt get usefull informations for
acme: error: 403 :: urn:ietf:params:acme:error:unauthorized :: During secondary validation: Incorrect validation certificate for tls-alpn-01 challenge. Requested traefik.demo.cloud.patrowl.io from 51.91.60.234:443. Received 1 certificate(s), first certificate had names \"ec5552cec6a19446c4eaf94ddd866262.82c4629185c6e4458ce087bec5fef363.traefik.default
traefik-service-443
Not sure about this config too.
To sum ip:
I have no problem with router - middleware - services about traefik but can’t figure out the acme with tls challenge. Always get default cert.
There is the url in logs where my server can be reached. It’s not import because it’s the demo instance and there is an auth basic http. I tried also without but I think, traefik let letsencrypt to get through.
If you have any clue, plz feel free to answer.
Thanks you and good luck during confinement