Traefik 配置总是返回 404
Traefik configuration always returning 404
我一定是犯了一些简单的错误,但是...为什么对这个 Traefik 服务器的每个请求都返回 404?
这里是traefik.yaml:
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
traefik:
address: ":9000"
providers:
file:
filename: traefik-routes.yaml
accessLog: {}
api:
insecure: true
dashboard: true
和 traefik-routes.yaml — 我正在尝试使用 PathPrefix(
/)
:
设置一条包罗万象的路线
http:
routers:
mistserver:
service: mistserver
rule: PathPrefix(`/`)
priority: 100
services:
mistserver:
loadBalancer:
servers:
- url: http://localhost:8080/
tls:
certificates:
- certFile: tls.crt
keyFile: tls.key
访问日志显示请求不匹配任何路由器。为什么?
[root@krabbucket traefik]# ./traefik --log.level=d
INFO[0000] Configuration loaded from file: /root/traefik/traefik.yaml
192.168.137.119 - - [09/Mar/2022:11:16:03 +0000] "GET / HTTP/2.0" - - "-" "-" 2 "-" "-" 0ms
192.168.137.119 - - [09/Mar/2022:11:16:03 +0000] "GET / HTTP/2.0" - - "-" "-" 3 "-" "-" 0ms
192.168.137.119 - - [09/Mar/2022:11:16:03 +0000] "GET / HTTP/2.0" - - "-" "-" 4 "-" "-" 0ms
当 traefik 尝试将您路由到它解析为 traefik 本身的服务时,您的服务 URL 被定义为 http://localhost:8080/
。
您要访问仪表板吗?如果是这样,将服务设置为 api@internal
http:
routers:
mistserver:
service: api@interna
rule: PathPrefix(`/`)
priority: 100
然后您可以通过 http://your-ip/dashboard/#/
访问仪表板
否则你的路由器和服务名称 mistserver
看起来你正试图访问机器本身的某些东西。
如果是这样,您将无法使用 localhost 访问您的计算机,因为它将解析为 traefik 本身。
但是您可以在 host mode.
中使用您的 public ip 地址而不是本地主机或 运行 traefik
事实证明,Traefik 在此上下文中需要单独的 TLS 和 non-TLS 路由。此修改后 traefik-routes.yaml
工作省长:
http:
routers:
mistserver:
service: mistserver
rule: PathPrefix(`/`)
priority: 100
mistserver-tls:
service: mistserver
rule: PathPrefix(`/`)
priority: 100
tls: {}
services:
mistserver:
loadBalancer:
servers:
- url: http://localhost:8080/
tls:
certificates:
- certFile: tls.crt
keyFile: tls.key
我一定是犯了一些简单的错误,但是...为什么对这个 Traefik 服务器的每个请求都返回 404?
这里是traefik.yaml:
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
traefik:
address: ":9000"
providers:
file:
filename: traefik-routes.yaml
accessLog: {}
api:
insecure: true
dashboard: true
和 traefik-routes.yaml — 我正在尝试使用 PathPrefix(
/)
:
http:
routers:
mistserver:
service: mistserver
rule: PathPrefix(`/`)
priority: 100
services:
mistserver:
loadBalancer:
servers:
- url: http://localhost:8080/
tls:
certificates:
- certFile: tls.crt
keyFile: tls.key
访问日志显示请求不匹配任何路由器。为什么?
[root@krabbucket traefik]# ./traefik --log.level=d
INFO[0000] Configuration loaded from file: /root/traefik/traefik.yaml
192.168.137.119 - - [09/Mar/2022:11:16:03 +0000] "GET / HTTP/2.0" - - "-" "-" 2 "-" "-" 0ms
192.168.137.119 - - [09/Mar/2022:11:16:03 +0000] "GET / HTTP/2.0" - - "-" "-" 3 "-" "-" 0ms
192.168.137.119 - - [09/Mar/2022:11:16:03 +0000] "GET / HTTP/2.0" - - "-" "-" 4 "-" "-" 0ms
当 traefik 尝试将您路由到它解析为 traefik 本身的服务时,您的服务 URL 被定义为 http://localhost:8080/
。
您要访问仪表板吗?如果是这样,将服务设置为 api@internal
http:
routers:
mistserver:
service: api@interna
rule: PathPrefix(`/`)
priority: 100
然后您可以通过 http://your-ip/dashboard/#/
否则你的路由器和服务名称 mistserver
看起来你正试图访问机器本身的某些东西。
如果是这样,您将无法使用 localhost 访问您的计算机,因为它将解析为 traefik 本身。
但是您可以在 host mode.
中使用您的 public ip 地址而不是本地主机或 运行 traefik事实证明,Traefik 在此上下文中需要单独的 TLS 和 non-TLS 路由。此修改后 traefik-routes.yaml
工作省长:
http:
routers:
mistserver:
service: mistserver
rule: PathPrefix(`/`)
priority: 100
mistserver-tls:
service: mistserver
rule: PathPrefix(`/`)
priority: 100
tls: {}
services:
mistserver:
loadBalancer:
servers:
- url: http://localhost:8080/
tls:
certificates:
- certFile: tls.crt
keyFile: tls.key