[英]Traefik Route Prefix
我已经用 config 配置了一个 Ingress:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nuclio-dashboard
namespace: nuclio
spec:
rules:
- host: nuc.local
http:
paths:
- path: /nuclio
backend:
serviceName: nuclio-dashboard
servicePort: 8070
不是当我 go 到nuc.local/nuclio
我收到响应但页面请求 js 和 css 文件时:
http://nuc.local/assets/css/vendor-fc43143698.css Failed to load resource: the server responded with a status of 404 (Not Found)
我希望从/nuclio
到/
到 go 到/nuclio
的每个请求法师。
我怎样才能做到这一点?
假设您使用的是 Traefik v2,您需要类似redirectRegex Middleware的东西,以便 traefik 执行此操作。 我认为它会像这样 go 。
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-redirectregex
namespace: nuclio
spec:
redirectRegex:
regex: ^http://nuc.local/?$$
replacement: http://nuc.local/nuclio/
permanent: true
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
traefik.ingress.kubernetes.io/router.middlewares: nuclio-test-redirectregex@kubernetescrd
name: nuclio-dashboard
namespace: nuclio
spec:
rules:
- host: nuc.local
http:
paths:
- path: /
backend:
serviceName: nuclio-dashboard
servicePort: 8070
另一种可能是使用replacePath Middleware ,它看起来像这样:
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: test-replacepath
namespace: nuclio
spec:
replacePath:
path: /nclio
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
traefik.ingress.kubernetes.io/router.middlewares: nuclio-test-replacepath@kubernetescrd
name: nuclio-dashboard
namespace: nuclio
spec:
rules:
- host: nuc.local
http:
paths:
- path: /
backend:
serviceName: nuclio-dashboard
servicePort: 8070
让我们知道情况如何。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.