Traefik: redirect www to non-www

Traefik: redirect www to non-www

Add the following to your traefik.yml

http:                                                                                                                        
  middlewares:
    www-redirect:
      redirectregex:                                
        regex: ^(?:https://)?(?:www\.)?(.+)
        replacement: https://${1}
        permanent: true

Now you can just add the following label to your docker container:

traefik.http.routers.REPLACE-THIS.middlewares: "www-redirect@file"