【发布时间】:2021-09-26 10:48:41
【问题描述】:
我使用 traefik 2.2.1 作为我的 kubernetes 入口控制器。现在我有一个 url 需要转发,这是我现在的 traefik 配置:
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
creationTimestamp: '2021-09-26T09:10:02Z'
generation: 4
name: uat-zhuolian-manage-route
namespace: dabai-uat
resourceVersion: '106700291'
selfLink: >-
/apis/traefik.containo.us/v1alpha1/namespaces/dabai-uat/ingressroutes/uat-zhuolian-manage-route
uid: d0b82fab-cd6a-49f0-96dc-f6c0f381bcc5
spec:
entryPoints:
- web
routes:
- kind: Rule
match: Host(`zhuolian-pro-manage.example.com`)
services:
- name: be-zhuolian-frontend
port: 80
- kind: Rule
match: Host(`zhuolian-pro-manage.example.com`) && Path(`/service`)
services:
- name: soa-zhuolian-service
port: 11032
我希望 traefik 做的是默认将 example.com 转发到 be-zhuolian-frontend。如果请求url中包含service,例如url为xxx.example.com/service/foo/bar,则转发到后端服务soa-zhuolian-service。但现在当我从远程云主机请求 url 时:
curl --header 'Host:zhuolian-pro-manage.example.com' http://172.19.104.230/service/zhuolian/report/user/captcha -L
显示错误:
[root@fat001 ~]# curl --header 'Host:zhuolian-pro-manage.example.com' http://172.19.104.230/service/zhuolian/report/user/captcha -L
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.19.0</center>
</body>
</html>
带有service关键字的url似乎仍然路由到前端服务,我应该如何解决这个问题并使service成功匹配后端服务?
【问题讨论】:
标签: kubernetes traefik