Domain not redirecting to Traefik dashboard

Thanks you two! I'm slowly beginning to understand how this works, but I'm not fully there yet. So I removed the things you guys mentioned and added the labels. I added what @rtribotte said:

traefik docker-compose
version: "3.3"

services:

  traefik:
    image: "traefik:v2.4"
    container_name: "traefik"
    command:
      - "--log.level=DEBUG"
      - "--api.dashboard=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myresolver.acme.httpchallenge=true"
      - "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
      #- "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
      - "--certificatesresolvers.myresolver.acme.email=xxx@xxx.com"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
      - "traefik.enable=true"
      - "traefik.http.routers.dashboard.rule=Host(`traefik.my.domain .com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))"
      - "traefik.http.routers.dashboard.entrypoints=websecure"
      - "traefik.http.routers.dashboard.tls.certresolver=myresolver"
      - "traefik.http.routers.dashboard.service=api@internal"

    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - "/home/pi/letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

I changed - "traefik.http.routers.dashboard.service=dashboard@internal" to api@internal, as that's what the documentation says.

A few questions came up:

  1. Do I need to use traefik.my.domain .com or my.domain.com in the dmains section?

  2. When going to https://my.domain .com, I still get an 404 error and unsecure certificate error. The log says this:

debug log
time="2021-01-25T15:26:32Z" level=debug msg="Configuration received from provider docker: {\"http\":{},\"tcp\":{},\"udp\":{}}" providerName=docker
time="2021-01-25T15:26:35Z" level=debug msg="No default certificate, generating one"
time="2021-01-25T15:26:38Z" level=debug msg="Added outgoing tracing middleware acme-http@internal" entryPointName=web routerName=acme-http@internal middlewareName=tracing middlewareType=TracingForwarder
time="2021-01-25T15:26:38Z" level=debug msg="Creating middleware" entryPointName=web middlewareName=traefik-internal-recovery middlewareType=Recovery
time="2021-01-25T15:26:38Z" level=debug msg="No default certificate, generating one"
time="2021-01-25T15:26:42Z" level=debug msg="No default certificate, generating one"
time="2021-01-25T15:26:45Z" level=debug msg="Added outgoing tracing middleware acme-http@internal" entryPointName=web routerName=acme-http@internal middlewareName=tracing middlewareType=TracingForwarder
time="2021-01-25T15:26:45Z" level=debug msg="Creating middleware" entryPointName=web middlewareName=traefik-internal-recovery middlewareType=Recovery
time="2021-01-25T15:26:45Z" level=debug msg="No default certificate, generating one"
time="2021-01-25T15:26:46Z" level=debug msg="No default certificate, generating one"
time="2021-01-25T15:27:19Z" level=debug msg="Serving default certificate for request: \"my.domain .com\""
time="2021-01-25T15:27:19Z" level=debug msg="http: TLS handshake error from xxx:xxx:xxx:xxx:xxxxx: remote error: tls: unknown certificate"
time="2021-01-25T15:27:21Z" level=debug msg="Serving default certificate for request: \"my.domain .com\""
time="2021-01-25T15:27:21Z" level=debug msg="http: TLS handshake error from xxx:xxx:xxx:xxx:xxxxx: remote error: tls: unknown certificate"
time="2021-01-25T15:27:21Z" level=debug msg="Serving default certificate for request: \"my.domain .com\""

I think the TLS error is the important part here. Googling this led me to this post. Since I want to automate this, the TLS documentation website led me to the Let's Encrypt Documentation page. TBH I'm having some trouble with the doumentation as basically in every paragraph I have to jump to another section of the documentation.

The "Enable ACME"-Config example is in my config already AFAIK. In the post I linked, they added something like the following to fix it. Is this something I have to add as well? I'm not quite sure where and how to..:

      tls:
        domains:
          - main: "sub.example .com"

(I've made a few spaces after the domains because as a new user I cannot post too many links :stuck_out_tongue: )

Edit: Ports 80 and 443 are opened. Checked with my DNS provider.