No dashboard with V2.2.1

Hi guys. I'm new to Traefik and I have searched the posts for several days, but still cann't set up a https dashboard and global redirect to https.
need advices or hints. thanks you . This is the docker-compose file.

version: '3.3'

services:
traefik:
image: traefik:v2.2.1
command:
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --api
- --providers.docker
- --providers.docker.exposedbydefault=false
- --log.level=DEBUG
- --log.filePath=/opt/traefik/traefik.log
- --certificatesresolvers.leresolver.acme.email=foo@yfoo.com
- --certificatesresolvers.leresolver.acme.storage=acme.json
- --certificatesresolvers.leresolver.acme.caserver=https://acme-v02.api.letsencrypt.org/directory
- --certificatesresolvers.leresolver.acme.dnschallenge=true
- --certificatesresolvers.leresolver.acme.dnschallenge.resolvers=ns1.dnsowl.com,ns2.dnsowl.com,1.1.1.1,8.8.8.8
- --certificatesresolvers.leresolver.acme.dnschallenge.provider=namesilo
- --accesslog=true
- --accesslog.filepath=/opt/traefik/access.log
- --accesslog.bufferingsize=10
ports:
- "80:80"
- "443:443"

volumes:
  - /etc/localtime:/etc/localtime:ro
   - /etc/timezone:/etc/timezone
  - /var/run/docker.sock:/var/run/docker.sock
  - ./certificates/acme.json:/acme.json
  - ./logs:/opt/traefik
networks:
  - proxy
environment:
  - NAMESILO_API_KEY=d2b14cfcc3ed6c8fd942
  - NAMESILO_PROPAGATION_TIMEOUT=3600
  - NAMESILO_POLLING_INTERVAL=60
labels:
  - "traefik.enable=true"
  - "traefik.docker.network=proxy"

  - "traefik.http.routers.http_catchall.rule=hostregexp(`{host:.+}`)"
  - "traefik.http.routers.http_catchall.entrypoints=web"
  - "traefik.http.routers.http_catchall.middlewares=redirect-to-https"
  - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
  - "traefik.http.middlewares.redirect-to-https.redicectscheme.permanent=true"


  - "traefik.http.routers.traefik.tls.certresolver=leresolver"
  - "traefik.http.routers.traefik.tls.domains[0].main=example.com"
  - "traefik.http.routers.traefik.tls.domains[0].sans=*.example.com"



  - "traefik.http.routers.traefik.rule=Host(`traefik.example.com`)"
  - "traefak.http.routers.traefik.service=api@internal"
  - "traefik.http.routers.traefik.entrypoints=websecure"
  - "traefik.http.routers.traefik.tls=true"
  - "traefik.http.routers.traefik.middlewares=auth"
  - "traefik.http.middlewares.auth.basicauth.users=user:$$apr1$$q8eZFHjF$$Fvmkk//V6Btlaf2i/ju5n/"

networks:
proxy:
external: true

How are you testing it? What is the result?

Here is a simple example compose. Add in auth middleware and certificate resolver.

version: "3.8"

services:
  traefik:
    image: "traefik:v2.2"
    command:
    - --entrypoints.web.address=:80
    - --entrypoints.web.http.redirections.entryPoint.to=websecure
    - --entrypoints.web.http.redirections.entryPoint.scheme=https
    - --entrypoints.web.http.redirections.entrypoint.permanent=true
    - --entrypoints.websecure.address=:443
    - --entrypoints.websecure.http.tls=true
    - --providers.docker=true
    - --providers.docker.exposedbydefault=false
    - --api
    labels:
      traefik.enable: "true"
      # traefik.http.routers.api.rule: Host(`foo.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
      traefik.http.routers.api.rule: PathPrefix(`/api`) || PathPrefix(`/dashboard`)
      traefik.http.routers.api.service: api@internal
      traefik.http.services.dummy.loadBalancer.server.port: 65535
      traefik.http.routers.api.entrypoints: websecure
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

Hi cakiwi,
thanks for your quick responses!
I tried your file(Add in auth middleware and certificate resolver) and the outcome as same as my original post.
It's when I changed the entrypoint from webseure to web. the dashboard can acessed on the url https://traefik.example.com:80/dashboard/
but with the vaue of "websecure " the browser can't open the page.
so the request cann't even get to the entrypoint?

You didn't specify an outcome in the first place. Which is why I asked:

404,500, connection timeout, 418 "I'm a teapot' ?

I think you're doing it wrong. Https is generally on port 443 and the port is not required.
Do you want https on port 80? That is a different configuration

Hi cakiwi,

I know it's ridiculous but finally, I found the common port 443 of the testing server was banned by local isp. so the browser simply returned the error of "timed out".
I have changed the default https port and then everything works well. Thank you for your informative replies.