我已经配置了一个入口:
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
不是当我去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
到/
的请求都转到/nuclio
。
我怎样才能做到这一点?
假设您使用的是Traefik v2,您需要redirectRegex中间件之类的东西,以便Traefik完成此操作。我想应该是这样的。
---
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中间件,它看起来像这样:
---
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
让我们知道是怎么回事。