我想在ingress kubernete重定向域名:
https://test.example.io/preview/qLxiVcDGxCaQ134650121853FTg4
重定向到:
https://test.app.example.io/preview/qLxiVcDGxCaQ134650121853FTg4
我尝试:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
certmanager.k8s.io/cluster-issuer: staging
nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.class: nginx
name: staging-ingress
spec:
rules:
- host: test.example.io
http:
paths:
- path: /
backend:
serviceName: service-1
servicePort: 80
- path: /preview/*
backend:
url:
serviceName: service-2
servicePort: 80
tls:
- hosts:
- test.example.io
secretName: staging
对于简单的nginx block像:
location ~ /preview
{
rewrite /preview https://test.app.example.com$uri permanent;
}
尝试:
metadata: annotations: nginx.ingress.kubernetes.io/configuration-snippet: | rewrite /preview https://test.app.example.com$uri permanent; spec: rules: - host: test.example.io http: paths: - path: / backend: serviceName: service-1 servicePort: 80 - host: test.app.example.io http: paths: - path: /preview/* backend: serviceName: service-2 servicePort: 80
在上面的代码中:你不能使用 https://test.app.example.io/preview/ (它只是重定向的链接)。
谢谢,我使用的是
server-snippet
,而不是configuration-snippet
,现在好了。再次感谢。你的答案