![Traefik 在 AWS 中收到“404 页面未找到”](https://linux22.com/image/750260/Traefik%20%E5%9C%A8%20AWS%20%E4%B8%AD%E6%94%B6%E5%88%B0%E2%80%9C404%20%E9%A1%B5%E9%9D%A2%E6%9C%AA%E6%89%BE%E5%88%B0%E2%80%9D.png)
我使用以下默认文件安装了 Traefik:https://docs.traefik.io/routing/providers/kubernetes-crd/#configuration-examples
我的入口路线看起来像这样:
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
annotations:
name: traefik-test-ingressroute
namespace: default
spec:
entryPoints:
- traefik
routes:
- kind: Rule
match: Host(`test.domain.com`)
services:
- name: whoami
port: 80
在仪表板中,规则看起来正确。它找到所有端点并标记为“成功”。但是当我将域“test.domain.com”放入浏览器时,它返回 404。我将此域与 Traefik 服务在 /etc/hosts 中创建的 AWS 负载均衡器的 IP 一起使用。
Traffik 正在到达 Traefik,因为在日志中,每次连接时我都会收到这样的日志,尝试:
172.20.59.64 - - [29/Mar/2020:22:19:47 +0000] "GET / HTTP/2.0" - - "-" "-" 190 "-" "-" 0ms
172.20.59.64 - - [29/Mar/2020:22:19:49 +0000] "GET / HTTP/2.0" - - "-" "-" 191 "-" "-" 0ms
172.20.59.64 - - [29/Mar/2020:22:19:49 +0000] "GET / HTTP/2.0" - - "-" "-" 192 "-" "-" 0ms
172.20.59.64 - - [29/Mar/2020:22:19:49 +0000] "GET / HTTP/2.0" - - "-" "-" 193 "-" "-" 0ms
172.20.59.64 - - [29/Mar/2020:22:19:49 +0000] "GET / HTTP/2.0" - - "-" "-" 194 "-" "-" 0ms
172.20.59.64 - - [29/Mar/2020:22:21:09 +0000] "GET / HTTP/2.0" - - "-" "-" 195 "-" "-" 0ms
答案1
我终于解决了问题。问题出在我的配置上。我们没有将 traefik 服务放入端点,而是将端点的名称配置在 traefik 参数中,例如:
--entryPoints.web.address=:80
因此配置应如下所示:
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
annotations:
name: traefik-test-ingressroute
namespace: default
spec:
entryPoints:
- web
routes:
- kind: Rule
match: Host(`test.domain.com`)
services:
- name: whoami
port: 80