Traefik v2 http 404 重定向到外部
一段时间以来,我无法解决看似简单的问题:
如何捕获未知路由器并将其重定向到外部域而不使用另一个反向代理(例如 nginx,如所述 这里)?
traefik:
...
labels:
- "traefik.enable=true"
- "traefik.http.routers.http_catchall.rule=HostRegexp(`{any:.+}`)"
- "traefik.http.routers.http_catchall.priority=1"
- "traefik.http.routers.http_catchall.entrypoints=unsecure"
- "traefik.http.routers.http_catchall.middlewares=error-catch,https-redirect"
- "traefik.http.middlewares.error-catch.errors.status=404"
- "traefik.http.middlewares.error-catch.errors.service=error-redirect"
- "traefik.http.middlewares.error-catch.errors.query=/"
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.https-redirect.redirectscheme.permanent=true"
# now how to use "error-redirect" service to forward to eg https://google.com
有什么想法吗?
For some time now I can't wrap my head around seemingly simple problem:
How to catch unknown routers and redirect it to external domain without using another reverse proxy (eg nginx as described here)?
traefik:
...
labels:
- "traefik.enable=true"
- "traefik.http.routers.http_catchall.rule=HostRegexp(`{any:.+}`)"
- "traefik.http.routers.http_catchall.priority=1"
- "traefik.http.routers.http_catchall.entrypoints=unsecure"
- "traefik.http.routers.http_catchall.middlewares=error-catch,https-redirect"
- "traefik.http.middlewares.error-catch.errors.status=404"
- "traefik.http.middlewares.error-catch.errors.service=error-redirect"
- "traefik.http.middlewares.error-catch.errors.query=/"
- "traefik.http.middlewares.https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.https-redirect.redirectscheme.permanent=true"
# now how to use "error-redirect" service to forward to eg https://google.com
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以添加一个 文件提供程序,在其中为外部 URL 定义服务。
并像这样在中间件中分配该服务
You can add a file provider in which you define a service for an external url.
and assign that service in the middleware like so