You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kubernetes中Helm部署NGINX-INGRESS出现404 Not Found求助

排查NGINX Ingress访问404的步骤

结合你提供的排查信息,几个关键方向可以优先检查:

1. 确认访问时的Host头是否匹配Ingress规则

你的Ingress规则仅匹配nginx.example.com这个Host,访问时必须满足以下任一条件:

  • 本地hosts文件添加映射:104.248.98.230 nginx.example.com,之后用域名访问
  • 用curl命令手动指定Host头:curl -H "Host: nginx.example.com" http://104.248.98.230

如果访问时未携带正确的Host头,Ingress Controller找不到对应的转发规则,就会返回404。

2. 检查后端nginx-service的状态

你目前仅查看了Ingress Controller的Service(nginx-ingress-nginx-ingress),但Ingress规则指向的是nginx-service:80,需要确认这个后端Service的状态:

  • 执行kubectl get svc -n default nginx-service,确认Service是否存在
  • 执行kubectl describe svc -n default nginx-service,检查Selector是否匹配NGINX Pod的标签(你的Pod标签是app=nginx-deployment,所以Service的Selector需对应为app=nginx-deployment)
  • 确认Service的Endpoints是否包含10.244.0.147:80,如果Endpoints为空,说明标签不匹配,Service无法找到Pod

3. 测试后端Pod的连通性

  • 从Ingress Controller Pod内测试:先找到Ingress Controller的Pod名(kubectl get pods -n default | grep nginx-ingress),再执行kubectl exec -it <ingress-controller-pod-name> -n default -- curl http://10.244.0.147:80,查看是否能返回NGINX默认页面
  • 如果集群内其他Pod能连通但Ingress Controller无法访问,检查是否有网络策略限制了Ingress Controller访问后端Pod

4. 查看Ingress Controller的日志

执行kubectl logs -n default <ingress-controller-pod-name>,查看请求到达后的日志,里面会显示请求的Host、路径,以及是否找到对应的后端规则、是否存在转发错误。


内容的提问来源于stack exchange,提问作者OpenDev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 07:40:22