[英]Traefik Route Prefix
I've configured an Ingress with config:我已经用 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
Not when I go to nuc.local/nuclio
I'm getting a response but the page requests js and css files at:不是当我 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)
I want every request mage from /nuclio
to /
to go to /nuclio
.我希望从/nuclio
到/
到 go 到/nuclio
的每个请求法师。
How can I accomplish this?我怎样才能做到这一点?
Assuming you're using Traefik v2, you need something like a redirectRegex Middleware , for traefik to do this.假设您使用的是 Traefik v2,您需要类似redirectRegex Middleware的东西,以便 traefik 执行此操作。 I think it would go like this.我认为它会像这样 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
Another take on it could be to use the replacePath Middleware , which would then look like this:另一种可能是使用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
Let us know how that goes.让我们知道情况如何。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.