I have a domain : mydomain.com
.
I host a blog under www.mydomain.com
, I want to redirect people that use mydomain.com
to www.mydomain.com
My proxy is traefik, and I use the HTTP-01
challenge to provide https
with let's encrypt.
So far, my configuration looks like this:
"traefik.enable": "true",
"traefik.http.routers.blogGateway.rule": "Host(`www.mydomain.com`) || Host(`mydomain.com`)",
"traefik.http.routers.blogGateway.entrypoints": "web-secure",
"traefik.http.routers.blogGateway.tls.certresolver": "httpChallengeLetsEncrypt",
"traefik.http.routers.blogGateway.tls.domains[0].main": "www.mydomain.com",
"traefik.http.routers.blogGateway.tls.domains[1].main": "mydomain.com",
"traefik.http.middlewares.redirect-to-https.redirectscheme.scheme": "https",
"traefik.http.routers.blogGatewayRedirs.rule": "hostregexp(`{host:.+}`)",
"traefik.http.routers.blogGatewayRedirs.entrypoints": "web",
"traefik.http.routers.blogGatewayRedirs.middlewares": "redirect-to-https"
This work, but it expose two domain instead of one.
I have tried to follow this tutorial : https://habd.as/post/redirect-non-www-to-www-traefik-v2-labels/ but I keep losing the track of my change, this configuration is somehow totally different from my current one.
How can I perform a redirect from @
to www
with traefik v2 ?