我们在AWS Kubernetes Service中托管了一个网站。我们遇到了以下问题。
issue1.css无法正常工作
问题2:重定向也无效
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: myapp1-alerts-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
cert-manager.io/issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/rewrite-target: "/"
spec:
tls:
- hosts:
- dev-api.myapp1.solutions
secretName: myapp1-alerts-tls
rules:
- host: dev-api.myapp1.solutions
http:
paths:
- path: /alerts
backend:
serviceName: myapp1-alerts
servicePort: 80
答案 0 :(得分:0)
看看official documentation。在那里,您将在下面找到一个示例:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: rewrite
namespace: default
spec:
rules:
- host: rewrite.bar.com
http:
paths:
- backend:
serviceName: http-svc
servicePort: 80
path: /something(/|$)(.*)
| kubectl create -f -
在此入口定义中,
(.*)
捕获的所有字符都将是 分配给占位符$2
,然后用作占位符 重写目标注释。例如,上面的入口定义将导致以下结果 重写:
rewrite.bar.com/something
重写为rewrite.bar.com/
rewrite.bar.com/something/
重写为rewrite.bar.com/
rewrite.bar.com/something/new
重写为rewrite.bar.com/new
相应地调整您的配置,请告诉我是否有帮助。