middleware - Traefik 中使用本地插件时中间件不存在
问题描述
我试图在相关帖子中找到答案,但我找不到它。
我创建了一个本地插件并以这种方式配置它:
traefik.toml
[experimental.localPlugins.myplugin]
moduleName = "test.com/traefik/myplugin"
.traefik.yml
displayName: Do some stuff
type: middleware
import: test.com/traefik/myplugin
summary:do a lot of nice stuffs
testData:
Headers:
Foo: Bar
我可以在日志中看到插件已加载:
Static configuration loaded {"global":{"checkNewVersion":true},"serversTransport":{"maxIdleConnsPerHost":200},"entryPoints":{"http":{"address":":80","transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s"}},"forwardedHeaders":{},"http":{},"udp":{"timeout":"3s"}},"traefik":{"address":":8080","transport":{"lifeCycle":{"graceTimeOut":"10s"},"respondingTimeouts":{"idleTimeout":"3m0s"}},"forwardedHeaders":{},"http":{},"udp":{"timeout":"3s"}}},"providers":{"providersThrottleDuration":"2s","docker":{"watch":true,"endpoint":"unix:///var/run/docker.sock","defaultRule":"Host(`{{ normalize .Name }}`)","exposedByDefault":true,"swarmModeRefreshSeconds":"15s"}},"api":{"insecure":true,"dashboard":true},"ping":{"entryPoint":"http","terminatingStatusCode":503},"log":{"level":"DEBUG","format":"common"},"accessLog":{"format":"json","filters":{},"fields":{"defaultMode":"keep","headers":{"defaultMode":"drop"}}},"pilot":{"dashboard":true}**,"experimental":{"localPlugins":{"myplugin":{"moduleName":"test.com/traefik/myplugin"}}}}
但是当我尝试像这样使用它时:
traefik.http.routers.myrouter.middlewares="testplugin-myplugin"
或者
traefik.http.routers.myrouter.middlewares="myplugin"
我收到如下错误:
middleware "testplugin-mypluginn@docker" does not exist
我正在使用 Traefik 2.5.2 docker image> 我尝试了一些静态和动态值的组合但没有运气:(我正在使用 Traefik 2.5.2 docker image。我尝试了一些静态和动态值的组合但没有运气:(我错过了一些配置吗?
解决方案
在文件中创建中间件时需要引用@file。否则,您会看到它正在寻找 testplugin-myplugin@docker,这意味着中间件是在 docker 规则中构建的。
尝试类似:
traefik.http.routers.myrouter.middlewares="myplugin@file"
推荐阅读
- android - 如果 chart.setVisibleXRangeMaximum 大于特定值,则条目的可绘制图标将消失
- assembly - 如何在程序集中打印 ASCII 数组?
- java - 有时无法使用 AWS SDK for Java v2.0 获取 s3 对象
- php - 从表单输入多行时缺少或未对齐的值 - PHP/MYSQLI
- c# - 如何从文件中删除行?
- java - 语音到文本应用程序用新文本替换旧文本
- html - 对齐问题:- 第二个帖子未正确对齐
- java - 如何使用hibernate在spring boot中的fillAll方法中添加where条件
- c# - 使用 OCR 的 pdf 中的黑屏编号
- python - 如何从保存的模型中获得文本预测准确性"