Define Middleware in toml file

I have a middleware definition in the traefik.toml

    permanent = true
    regex = "https://(.*)/.well-known/(card|cal)dav"
    replacement = "https://${1}/remote.php/dav/"

(When I change it so that the syntax is invalid, I get an error, so I'm pretty sure, the file gets loaded.) However, in the dashboard and logs the "nextcloud-redirectregex" middleware is not to be found. Also, when referring to it with


I get "middleware "nextcloud-redirectregex@file" does not exist". Defining the same rule in a Docker compose file works.

Do you have any error logs generated by Traefik? If you don't see the middleware in the dashboard that means it has not been loaded correctly and there should be any log entry explaining the reason.

I couldn't find any mention of the middleware in the logs. Only the internal middlewares appeared.

This is usually the static config file. Middlewares need to be configured in a dynamic provider.

This can be defined in docker labels or in a file provider in toml format. You will have to configure the file provider to file path or directory.

I also got the same, no idea why it only works when I define in docker-compose labels

    stsSeconds = 15552000
    stsIncludeSubdomains = true
    stsPreload = true
    forceSTSHeader = true

    regex = "https://(.*)/.well-known/(card|cal)dav"
    replacement = "https://${1}/remote.php/dav/"
    permanent = true

=> Not work

- "traefik.http.middlewares.nextcloudHeader.headers.stsSeconds=15552000"
- "traefik.http.middlewares.nextcloudHeader.headers.stsIncludeSubdomains=true"
- "traefik.http.middlewares.nextcloudHeader.headers.stsPreload=true"
- "traefik.http.middlewares.nextcloudHeader.headers.forceSTSHeader=true"
- "traefik.http.middlewares.nextcloudRedirect.redirectRegex.regex=https://(.*)/.well-known/(card|cal)dav"
- "traefik.http.middlewares.nextcloudRedirect.redirectRegex.replacement=https://$${1}/remote.php/dav/"
- "traefik.http.middlewares.nextcloudRedirect.redirectRegex.permanent=true"

=> Work

and always have this for both cases

- traefik.enable=true
- traefik.http.routers.nextcloud.rule=Host(`${NEXTCLOUD_SUBDOMAIN}.${DOMAIN_NAME}`)
- traefik.http.routers.nextcloud.tls.certresolver=myresolver
- traefik.http.routers.nextcloud.entrypoints=websecure
- traefik.http.routers.nextcloud.middlewares=nextcloudHeader,nextcloudRedirect

You have the same? You put the dynamic configuration in the static configuration file?
The answer is the same, put the dynamic configuration in a file-provider.