【发布时间】:2021-08-13 20:41:56
【问题描述】:
我太笨了,谷歌也没用。
我正在尝试设置最简单的配置:
- Traefik 2(在最新的 Docker 容器中),处理传入的请求...
- 应该将所有传入请求(http、https)定向到另一个服务,Traefik whoami 演示容器(我已经在运行)...
- 在终止 SSL 连接时,通过端口 80 上的 http 调用服务...
- 使用具有明确定义的路由的配置文件时
我将如何配置它?这是我的尝试:
entryPoints:
web:
address: :80
websecure:
address: :443
log:
filePath: "/home/LogFiles/traefik.log"
level: DEBUG
accessLog:
filePath: "/home/LogFiles/trafik-access.log"
providers:
file:
filename: "/home/traefik.yml"
http:
routers:
route-https:
rule: "Host(`traefik-test.azurewebsites.net`) && PathPrefix(`/whoami`)"
service: "whoami"
tls: {}
route-http:
rule: "Host(`traefik-test.azurewebsites.net`) && PathPrefix(`/whoami`)"
service: "whoami"
services:
whoami:
loadBalancer:
servers:
- url: "http://whoami-test.azurewebsites.net/"
我不确定 https 到 http 的转换是如何工作的。文档说它是自动发生的。 Another part of the doc 表示您必须使用两个路由器,tls: {} 部分告诉终止 TLS 连接。这就是我在上面所做的。 (对吗?)
可以在浏览器中通过http和https毫无问题地访问whomami服务URL。但是当通过 Traefik 调用它时(对于上面的示例,这将是 https://traefik-test.azurewebsites.net/whoami)我得到一个 400 并且浏览器显示“错误请求”。我怀疑 https->http 部分不起作用。
网络上的示例通常展示了如何编排由 Traefik 发现的多个容器。这不是我在这里做的。我只想告诉 Treafik 我已经在运行的服务。接受每个请求,通过 http 将所有内容路由到我的服务。应该很简单吧?
感谢任何提示。
【问题讨论】:
标签: traefik