成功设置TLS后,我无法通过入口访问我的Web应用程序,因为它始终重定向到404默认后端
这是我的入口配置:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-service
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
kubernetes.io/ingress.class: nginx
certmanager.k8s.io/cluster-issuer: 'letsencrypt-prod'
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
spec:
tls:
- hosts:
- xxxx.com
- www.xxxx.com
secretName: xxxx-com
rules:
- host: xxxx.com
- http:
paths:
- path: /(.*)
backend:
serviceName: web-cluster-ip-service
servicePort: 3000
- host: www.xxxx.com
- http:
paths:
- path: /(.*)
backend:
serviceName: web-cluster-ip-service
servicePort: 3000
删除TLS选项可以使其正常工作(认为不再使用TLS):
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-service
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
kubernetes.io/ingress.class: nginx
spec:
rules:
- http:
paths:
- path: /(.*)
backend:
serviceName: web-cluster-ip-service
servicePort: 3000
最佳答案
没什么,几个小时后,我发现我的配置有错误:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-service
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
kubernetes.io/ingress.class: nginx
certmanager.k8s.io/cluster-issuer: 'letsencrypt-prod'
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
spec:
tls:
- hosts:
- xxxx.com
- www.xxxx.com
secretName: xxxx-com
rules:
- host: xxxx.com
http:
paths:
- path: /(.*)
backend:
serviceName: web-cluster-ip-service
servicePort: 3000
- host: www.xxxx.com
http:
paths:
- path: /(.*)
backend:
serviceName: web-cluster-ip-service
servicePort: 3000
每个主机块中的HTTP前均应删除连字符
那是...很难找到,在应用可能的古怪/错误配置时出现警告消息不会伤害任何人
关于nginx - kubernetes nginx-ingress始终重定向到404默认backen忽略路径规则,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58034056/