@file是用来引用中间件配置文件的。如果你想使用它,需要在Traefik的配置文件中定义中间件,并将它们保存到文件中。然后,在路由规则中使用@file来引用这些中间件。

例如,你可以在Traefik的配置文件中定义一个名为https-redirect的中间件,如下所示:

[http.middlewares]
  [http.middlewares.https-redirect.redirectScheme]
    scheme = "https"

然后,将此中间件保存到文件/path/to/middleware/https-redirect.toml中。最后,在路由规则中使用@file来引用此文件中的中间件,如下所示:

traefik.http.routers.traefik-dash-default.middlewares=https-redirect@file:/path/to/middleware/https-redirect.toml

这将使Traefik从文件中加载https-redirect中间件,并将其应用于路由规则traefik-dash-default

traefikhttprouterstraefik-dash-defaultmiddlewares=https-redirectfile里面的file是在哪里定义的?要自己写吗?

原文地址: https://www.cveoy.top/t/topic/be2Y 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录