[英]Nginx Ingress Controller Returns 404 Kubernetes
I am trying to create an ingress controller that points to a service that I have exposed via NodePort.我正在尝试创建一个指向我通过 NodePort 公开的服务的入口 controller。
Here is the yaml file for the ingress controller (taken from https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/ ):这是入口 controller 的 yaml 文件(取自https://kubernetes.io/docs/tasks/access-application-cluster )
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- host: hello-world.info
http:
paths:
- path: /
backend:
serviceName: appName
servicePort: 80
I can connect directly to the node port and the frontend is displayed.我可以直接连接到节点端口并显示前端。
Please note that I am doing this because the frontend app is unable to connect to other deployments that I have created and I read that an ingress controller would be able to solve the issue.请注意,我这样做是因为前端应用程序无法连接到我创建的其他部署,并且我读到入口 controller 将能够解决该问题。 Will I still have to add an Nginx reverse proxy?
我还需要添加 Nginx 反向代理吗? If so how would I do that?
如果是这样,我会怎么做? I have tried adding this to the nginx config file but with no success.
我尝试将其添加到 nginx 配置文件中,但没有成功。
location /middleware/ {
proxy_pass http://middleware/;
}
You must use a proper hostname to reach the route defined in the Ingress
object.您必须使用正确的主机名才能到达
Ingress
object 中定义的路由。 Either update your /etc/hosts
file or use curl -H "hello-world.info" localhost
type command.更新您的
/etc/hosts
文件或使用curl -H "hello-world.info" localhost
类型命令。 Alternatively, you can delete the host
mapping and redirect all traffic to one default service.或者,您可以删除
host
映射并将所有流量重定向到一个默认服务。
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- http:
paths:
- path: /
backend:
serviceName: appName
servicePort: 80
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.