[英]kubernetes nginx-ingress always redirecting to 404 default backen ignoring path rules
After setting TLS succesfully, i'm not able to reach my web application through the ingress, since it is always redirecting to 404 default backend成功设置 TLS 后,我无法通过入口访问我的 web 应用程序,因为它始终重定向到 404 默认后端
This is my ingress configuration:这是我的入口配置:
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
Removing TLS options make it work fine (thought is not using TLS anymore):删除 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
Nevermid, after many hours i found that my configuration has an error: Nevermid,几个小时后我发现我的配置有错误:
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
Hypens should be removed before http in each host block应在每个主机块中的 http 之前删除连字符
That was... hard to find, a warning message when applying a possible weird/wrong configuration would not have hurt anyone那是......很难找到,应用可能的奇怪/错误配置时的警告消息不会伤害任何人
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.