I'm experiencing the same issue. I can't get a global redirect to work.
My thought is, that the regular expression, doesn't work for me, since I'm using service.home.domain.tld instead of service.domain.tld.
Don't worry about the port bend. I'm sitting behind a router that redirects the ports correctly. I just can't use the default ports on that machine, since they're in use by my NAS Software and other services locally. SSL Certs, accessing via https etc.everyhting works fine.
traefik docker-compose.yml: (As you can see, I even tried to match the host/service to no avail)
version: '3.5'
services:
traefik:
image: traefik:2.0.2
container_name: traefik
command:
- --log.level=DEBUG
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --certificatesresolvers.le.acme.email=MAIL
- --certificatesresolvers.le.acme.storage=/acme.json
- --certificatesResolvers.le.acme.dnsChallenge.provider=cloudflare
- --certificatesresolvers.le.acme.dnschallenge=true
- --providers.docker=true
- --api
- --providers.docker.exposedByDefault=false
- --providers.file.filename=/etc/traefik/rules.yml
- --providers.file.watch=true
environment:
CF_API_EMAIL: "MAIL"
CF_API_KEY: "CFKEY"
ports:
- "81:80"
- "8099:8080"
- "444:443"
networks:
- web
labels:
# Dashboard
- "traefik.http.routers.traefik.rule=Host(`api.home.domain.tld`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.tls.certresolver=le"
- "traefik.http.routers.traefik.entrypoints=websecure"
# Dashboard auth
# insert here
# middleware redirect
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
# global redirect to https
- "traefik.http.routers.redirs.entrypoints=web"
# - "traefik.http.routers.redirs.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.redirs.rule=Host(`whoami.home.domain.tld`)"
- "traefik.http.routers.redirs.middlewares=redirect-to-https@docker"
volumes:
# - ./traefik.toml:/etc/traefik/traefik.toml
- ./rules.yml:/etc/traefik/rules.yml
- ./acme.json:/acme.json
- /var/run/docker.sock:/var/run/docker.sock
- traefik_data:/tmp
networks:
web:
external: true
volumes:
traefik_data:
whoami docker-compose.yml
version: "2"
services:
whoami:
image: jwilder/whoami
container_name: "whoami"
labels:
- traefik.enable=true
# - traefik.http.middlewares.whoami-https.redirectscheme.scheme=https
# - traefik.http.routers.whoami-http.entrypoints=web
# - traefik.http.routers.whoami-http.rule=Host(`whoami.home.domain.tld`)
# - traefik.http.routers.whoami-http.middlewares=whoami-https@docker
- traefik.http.routers.whoami.entrypoints=websecure
- traefik.http.routers.whoami.rule=Host(`whoami.home.domain.tld`)
- traefik.http.routers.whoami.tls=true
- traefik.http.routers.whoami.tls.certresolver=le
- traefik.http.services.whoami.loadbalancer.server.port=8000
networks:
- web
restart: unless-stopped
networks:
web:
external: true
Accessing the http version throws me a 404 and the debug log of traffic does not show any kind of access on that entrypoint/router.
traefik debug.log (hope its not too reducted)
Starting traefik ... done
Attaching to traefik
traefik | time="2019-10-15T16:26:07Z" level=info msg="Configuration loaded from flags."
traefik | time="2019-10-15T16:26:07Z" level=info msg="Traefik version 2.0.2 built on 2019-10-09T19:26:05Z"
traefik | time="2019-10-15T16:26:07Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"web\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}},\"websecure\":{\"address\":\":443\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000,\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000},\"file\":{\"watch\":true,\"filename\":\"/etc/traefik/rules.yml\"}},\"api\":{\"dashboard\":true},\"log\":{\"level\":\"DEBUG\",\"format\":\"common\"},\"certificatesResolvers\":{\"le\":{\"acme\":{\"email\":\"MAIL\",\"caServer\":\"https://acme-v02.api.letsencrypt.org/directory\",\"storage\":\"/acme.json\",\"keyType\":\"RSA4096\",\"dnsChallenge\":{\"provider\":\"cloudflare\"}}}}}"
traefik | time="2019-10-15T16:26:07Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://docs.traefik.io/v2.0/contributing/data-collection/\n"
traefik | time="2019-10-15T16:26:07Z" level=debug msg="No default certificate, generating one"
traefik | time="2019-10-15T16:26:08Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"
traefik | time="2019-10-15T16:26:08Z" level=debug msg="Start TCP Server" entryPointName=web
traefik | time="2019-10-15T16:26:08Z" level=debug msg="Start TCP Server" entryPointName=websecure
traefik | time="2019-10-15T16:26:08Z" level=info msg="Starting provider *file.Provider {\"watch\":true,\"filename\":\"/etc/traefik/rules.yml\"}"
traefik | time="2019-10-15T16:26:08Z" level=info msg="Starting provider *acme.Provider {\"email\":\"MAIL\",\"caServer\":\"https://acme-v02.api.letsencrypt.org/directory\",\"storage\":\"/acme.json\",\"keyType\":\"RSA4096\",\"dnsChallenge\":{\"provider\":\"cloudflare\"},\"ResolverName\":\"le\",\"store\":{},\"ChallengeStore\":{}}"
traefik | time="2019-10-15T16:26:08Z" level=info msg="Testing certificate renew..." providerName=le.acme
traefik | time="2019-10-15T16:26:08Z" level=info msg="Starting provider *docker.Provider {\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}"
traefik | time="2019-10-15T16:26:08Z" level=debug msg="Configuration received from provider file: {\"http\":{},\"tcp\":{},\"tls\":{}}" providerName=file
traefik | time="2019-10-15T16:26:08Z" level=debug msg="Configuration received from provider le.acme: {\"http\":{},\"tls\":{}}" providerName=le.acme
traefik | time="2019-10-15T16:26:08Z" level=debug msg="No default certificate, generating one"
traefik | time="2019-10-15T16:26:08Z" level=debug msg="Provider connection established with docker 19.03.3 (API 1.40)" providerName=docker
// Filtering disabled Containers //
traefik | time="2019-10-15T16:26:08Z" level=debug msg="Configuration received from provider docker: {\"http\":{},\"tcp\":{}}" providerName=docker
traefik | time="2019-10-15T16:26:09Z" level=debug msg="Adding certificate for domain(s) whoami.home.domain.tld"
traefik | time="2019-10-15T16:26:09Z" level=debug msg="No default certificate, generating one"
traefik | time="2019-10-15T16:26:11Z" level=debug msg="Adding certificate for domain(s) whoami.home.domain.tld"
traefik | time="2019-10-15T16:26:11Z" level=debug msg="No default certificate, generating one"
traefik | time="2019-10-15T16:26:37Z" level=debug msg="Provider event received {Status:start ID:5de4666692a095f4c66559b684a3276fdc5363dcdfa6a7304bf0a63e37d47ca4 From:jwilder/whoami Type:container Action:start Actor:{ID:5de4666692a095f4c66559b684a3276fdc5363dcdfa6a7304bf0a63e37d47ca4 Attributes:map[com.docker.compose.config-hash:1f71bfe9bf9a3e93cf7ffaf99cd568d97652a4fce79f5026b8570ccc6e6cee17 com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:whoami com.docker.compose.service:whoami com.docker.compose.version:1.23.2 image:jwilder/whoami name:whoami traefik.enable:true traefik.http.routers.whoami.entrypoints:websecure traefik.http.routers.whoami.rule:Host(`whoami.home.domain.tld`) traefik.http.routers.whoami.tls:true traefik.http.routers.whoami.tls.certresolver:le traefik.http.services.whoami.loadbalancer.server.port:8000]} Scope:local Time:1571156797 TimeNano:1571156797257080032}" providerName=docker
// Filtering disabled Containers //
traefik | time="2019-10-15T16:26:37Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"whoami\":{\"entryPoints\":[\"websecure\"],\"service\":\"whoami\",\"rule\":\"Host(`whoami.home.domain.tld`)\",\"tls\":{\"certResolver\":\"le\"}}},\"services\":{\"whoami\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.18.0.3:8000\"}],\"passHostHeader\":true}}}},\"tcp\":{}}" providerName=docker
traefik | time="2019-10-15T16:26:37Z" level=debug msg="Adding certificate for domain(s) whoami.home.domain.tld"
traefik | time="2019-10-15T16:26:37Z" level=debug msg="No default certificate, generating one"
traefik | time="2019-10-15T16:26:38Z" level=debug msg="Creating middleware" middlewareType=Pipelining entryPointName=websecure routerName=whoami@docker serviceName=whoami middlewareName=pipelining
traefik | time="2019-10-15T16:26:38Z" level=debug msg="Creating load-balancer" entryPointName=websecure routerName=whoami@docker serviceName=whoami
traefik | time="2019-10-15T16:26:38Z" level=debug msg="Creating server 0 http://172.18.0.3:8000" serverName=0 entryPointName=websecure routerName=whoami@docker serviceName=whoami
traefik | time="2019-10-15T16:26:38Z" level=debug msg="Added outgoing tracing middleware whoami" entryPointName=websecure routerName=whoami@docker middlewareName=tracing middlewareType=TracingForwarder
traefik | time="2019-10-15T16:26:38Z" level=debug msg="Creating middleware" entryPointName=websecure middlewareName=traefik-internal-recovery middlewareType=Recovery
traefik | time="2019-10-15T16:26:38Z" level=debug msg="Try to challenge certificate for domain [whoami.home.domain.tld] founded in HostSNI rule" routerName=whoami rule="Host(`whoami.home.domain.tld`)" providerName=le.acme
traefik | time="2019-10-15T16:26:38Z" level=debug msg="Looking for provided certificate(s) to validate [\"whoami.home.domain.tld\"]..." providerName=le.acme routerName=whoami rule="Host(`whoami.home.domain.tld`)"
traefik | time="2019-10-15T16:26:38Z" level=debug msg="No ACME certificate generation required for domains [\"whoami.home.domain.tld\"]." providerName=le.acme routerName=whoami rule="Host(`whoami.home.domain.tld`)"
traefik | time="2019-10-15T16:26:45Z" level=debug msg="Provider event received {Status:die ID:5de4666692a095f4c66559b684a3276fdc5363dcdfa6a7304bf0a63e37d47ca4 From:jwilder/whoami Type:container Action:die Actor:{ID:5de4666692a095f4c66559b684a3276fdc5363dcdfa6a7304bf0a63e37d47ca4 Attributes:map[com.docker.compose.config-hash:1f71bfe9bf9a3e93cf7ffaf99cd568d97652a4fce79f5026b8570ccc6e6cee17 com.docker.compose.container-number:1 com.docker.compose.oneoff:False com.docker.compose.project:whoami com.docker.compose.service:whoami com.docker.compose.version:1.23.2 exitCode:137 image:jwilder/whoami name:whoami traefik.enable:true traefik.http.routers.whoami.entrypoints:websecure traefik.http.routers.whoami.rule:Host(`whoami.home.domain.tld`) traefik.http.routers.whoami.tls:true traefik.http.routers.whoami.tls.certresolver:le traefik.http.services.whoami.loadbalancer.server.port:8000]} Scope:local Time:1571156805 TimeNano:1571156805986671916}" providerName=docker
// Filtering disabled Containers //
traefik | time="2019-10-15T16:26:46Z" level=debug msg="Configuration received from provider docker: {\"http\":{},\"tcp\":{}}" providerName=docker
traefik | time="2019-10-15T16:26:46Z" level=debug msg="Adding certificate for domain(s) whoami.home.domain.tld"
traefik | time="2019-10-15T16:26:46Z" level=debug msg="No default certificate, generating one"
^CGracefully stopping... (press Ctrl+C again to force)
Stopping traefik ... done