Cannnot establish secure connection to www.*.com

Hey, I have the following docker-compose setup for deploying my app + traefik reverse proxy.


Everything works fine when I try to access my website at *.com and I do get secure connection, but trying to open www.*.com leads to unsecure connection saying that my certificate is not valid, and it is self-signed.
I am deploying this using an AWS EC2 instance and I do have a CNAME record there which should make the www.*.com be an alias of *.com.

Do you know what might be the problem? Thank you!

You need to specify all (sub-)domains in rule, check simple Traefik example:

  whoami:
    image: traefik/whoami:v1.10
    networks:
      - proxy
    labels:
      - traefik.enable=true
      - traefik.http.routers.mywhoami.rule=Host(`whoami.example.com`) || Host(`www.whoami.example.com`)
      - traefik.http.services.mywhoami.loadbalancer.server.port=80
      
      # next lines are optional to redirect www to non-www
      - traefik.http.middlewares.mywwwredirect.redirectregex.regex=^https://www\.(.*)
      - traefik.http.middlewares.mywwwredirect.redirectregex.replacement=https://$${1}
      - traefik.http.routers.mywhoami.middlewares=mywwwredirect

Thank you, works like a charm!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.