HTTP to HTTPs redirect not working

I've setup a traefik webrouter and redirected TCP80 and TCP443 to it as default. EntryPoints in traefik.toml are web and websecure as you can see here:

    address = ":80"
    address = ":443"

  email = "XXXX"
  storage = "/etc/traefik/acme.json"
    entryPoint = "web"

  filename = "/etc/traefik/traefik_dynamic.toml"

Now i tried to implement a rule which listens on HTTP and HTTPS and if clients connect to HTTP it redirects to HTTPS in default. That ist this configuration in traefik_dynamic.toml

      entryPoints = ["web"]
      service = "npm"
      rule = "Host(``)"
      middlewares = ["httpsRedirect"]
      entryPoints = ["websecure"]
      service = "npm"
      rule = "Host(``)"
        certResolver = "letsencrypt"

          url = ""

    scheme = "https"
    permanent = "true"

But that returns 404 and doesnt work. I already got it working with HTTPS OR HTTP only. But not both (unfortunately i deleted the working HTTPS and HTTP config; stupid me). What would be the correct way to implement a HTTP to HTTPS redirect?

I recommend to simply place the redirect and certresolver globally on entrypoints, see simple Traefik example (command=static, labels=dynamic).