Best practise to declare for global middlewares in docker compose


I have been wondering what is the best practise to declare a middleare which is used globally?
First of all with "global" middlewares i refer to middlewares which are not used on a service but are used on a entrypoint (and thus on all services using that entrypoint)
I want to manage everything inside my docker-compose.yaml files. Declaring a middleare which is used on my only entrypoint websecure as a label on one of my two services seems unintuitive.
For me it seems more reasonable to declare it in the same section where a set it: in command line arguments.
In the command line arguments I can assign default middlewares using --entrypoints.<name>.http.middlewares to my entry point, but I can not declare one?

So my best workaround was to create a dummy container / service where I declare my global middleware like so:

    image: alpine:3.18.3
      - sleep
      - infinity
      - "traefik.enable=true"
      - "traefik.http.middlewares.non-www-to-www.redirectregex.regex=^https://${FQDN:?}/(.*)"
      - "traefik.http.middlewares.non-www-to-www.redirectregex.replacement=https://www.${FQDN:?}/$${1}"
      - "traefik.http.middlewares.non-www-to-www.redirectregex.permanent=true"
      - 80
    restart: always

But this also does not feel right. What is the best practice for my use case?

According to the static config reference you can not declare a middleware there.