【发布时间】:2021-09-07 16:58:45
【问题描述】:
我有一个简单的 Golang 微服务(没有 Docker,只是简单的二进制文件),它在 GET 请求上返回简单的消息。
curl -XGET 'http://localhost:36001/api/operability/list'
{“消息”:“ping 123”}
现在我想通过 Traefik-v2 做反向代理,所以我制作了配置文件“traefik.toml”:
[global]
checkNewVersion = false
sendAnonymousUsage = false
[entryPoints]
[entryPoints.web]
address = ":8090"
[entryPoints.traefik]
address = ":8091"
[log]
level = "DEBUG"
filePath = "logs/traefik.log"
[accessLog]
filePath = "logs/access.log"
[api]
insecure = true
dashboard = true
[providers]
[providers.file]
filename = "traefik.toml"
# dynamic conf
[http]
[http.routers]
[http.routers.my-router]
rule = "Path(`/proxy`)"
service = "my-service"
entryPoints = ["web"]
[http.services]
[http.services.my-service.loadBalancer]
[[http.services.my-service.loadBalancer.servers]]
url = "http://localhost:36001"
启动 Traefik(我使用的是二进制分发):
traefik --configFile=traefik.toml
现在端口 8091 上的仪表板就像一个魅力,但我在处理反向代理请求时遇到了困难。我想它应该看起来像这样(基于我的配置文件):
curl -XGET 'http://localhost:8090/proxy/api/operability/list'
但我得到的只是:
404 页面未找到
问题是:配置文件有什么错误还是只是请求拼写错误?
编辑: 我的配置文件基于以下问题的答案:
编辑#2: Traefik 版本信息:
traefik version
Version: 2.4.9
Codename: livarot
Go version: go1.16.5
Built: 2021-06-21T16:17:58Z
OS/Arch: windows/amd64
【问题讨论】:
标签: go networking microservices reverse-proxy traefik