Hi, guys. I am new in Traefik. And I've stuck in problem of configuring www to non-www redirection globally in Traefik config:
Here is related configs:
STATIC:
entryPoints:
web:
address: :80
http:
redirections:
entryPoint:
to: websecure
websecure:
address: :443
http:
middlewares:
- secureHeaders@file
- nofloc@file
- www_cut@file
tls:
certResolver: letsencrypt
DYNAMIC:
http:
middlewares:
nofloc:
headers:
customResponseHeaders:
Permissions-Policy: "interest-cohort=()"
secureHeaders:
headers:
sslRedirect: true
forceSTSHeader: true
stsIncludeSubdomains: true
stsPreload: true
stsSeconds: 31536000
www_cut:
redirectRegex:
permanent: true
regex: "^https?://(?:www\\.)?(.+)"
replacement: "https://${1}"
# regex: "^(www\\.)?(.+)"
# replacement: "https://${2}"
As you can see I am trying to attach www_cut middleware to the websecure entry point
when I am trying to get to www.blog.mydomain.ru I am getting in logs:
raefik | time="2021-05-23T20:15:42Z" level=debug msg="Serving default certificate for request: "www. blog .mydomain. ru""
traefik | time="2021-05-23T20:15:42Z" level=debug msg="http: TLS handshake error from 109.197.103.92:51229: read tcp 172.28.0.4:443->109.197.103.92:51229: read: connection reset by peer"
traefik | time="2021-05-23T20:15:43Z" level=debug msg="Serving default certificate for request: "www. blog .mydomain .ru""
traefik | time="2021-05-23T20:15:43Z" level=debug msg="http: TLS handshake error from 109.197.103.92:51230: EOF"
traefik | time="2021-05-23T20:15:43Z" level=debug msg="http: TLS handshake error from 109.197.103.92:51231: tls: client offered only unsupported versions: [301]"
traefik | time="2021-05-23T20:15:43Z" level=debug msg="Serving default certificate for request: "www .blog .mydomain. ru""
traefik | time="2021-05-23T20:15:44Z" level=debug msg="http: TLS handshake error from 109.197.103.92:51232: read tcp 172.28.0.4:443->109.197.103.92:51232: read: connection reset by peer"
Appreciate your help.