Nginx ingress host 404 ip found

Martin Smola

I am beginner with Kubernetes. I tried to deploy Prometheus from helm and now I need to setup Ingress in internal network.

I have problem with resolving Prometheus by hostname. If I use IP address I get it work but when I use syntax "host" it is 404 error. I don't know why is not resolved by hostname. I used kubespray for deploy Kubernetes.

Could you help me, please?

Ingress

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: prometheus-ingress
  namespace: monitoring
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - prom.tipsport.it
    secretName: foo-tls
  rules:
  - host: prom.cluster.local
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: prometheus-kube-prometheus-prometheus
            port:
              number: 9090


Describe pod
Name:             prometheus-ingress
Namespace:        monitoring
Address:          10.10.10.3,10.10.10.4,10.10.10.5
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
TLS:
  foo-tls terminates prom.tipsport.it
Rules:
  Host        Path  Backends
  ----        ----  --------
  *           
              /   prometheus-kube-prometheus-prometheus:9090 (10.233.66.116:9090)
Annotations:  nginx.ingress.kubernetes.io/enable-cors: true
              nginx.ingress.kubernetes.io/rewrite-target: /
Events:
  Type    Reason  Age                  From                      Message
  ----    ------  ----                 ----                      -------
  Normal  Sync    7m36s (x8 over 61m)  nginx-ingress-controller  Scheduled for sync
  Normal  Sync    7m35s (x8 over 61m)  nginx-ingress-controller  Scheduled for sync
  Normal  Sync    7m34s (x8 over 61m)  nginx-ingress-controller  Scheduled for sync
coderanger

What you want is this:

  rules:
  - host: prom.tipsport.it
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: prometheus-kube-prometheus-prometheus
            port:
              number: 9090

The host: field tells it which Host header to route where so it should be the public hostname. Also it should be in the same section as the http: field which gives further routing instructions. also you don't need the rewrite target annotation since no rewriting is needed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Kubenetes Ingress-Nginx 404 not found

Kubernetes NGINX Ingress Controller 404 Not found / Object not found

How to add blocking IP rules on each nginx-ingress host

nginx-ingress - https configuration - server IP address could not be found

Problem with host, with minikube + nginx ingress

Kubernetes Ingress Whitelist IP for host

NGINX Ingress Annotations creates 404

Nginx ingress controller returns 404

Can I get response of curl through POD IP address (instead of host address) while using nginx ingress

404 page not found when kubernetes ingress-nginx is run on docker windows

Nginx Ingress: service "ingress-nginx-controller-admission" not found

Forge / Nginx - 404 Not Found

NGINX htpasswd 404 not found

404 Not Found nginx React

Nginx Ingress Controller: What is the purpose of the host variable?

AKS Ingress-Nginx ingress controller failing to route by host

Kubernetes Ingress Nginx loading resources 404

Nginx Ingress Controller Returns 404 Kubernetes

nginx ingress routing (default backend 404)

404 Not Found when migrating from ingress to istio

Bind nginx-ingress to static IP Address

GKE Nginx Ingress - Assigning static ip

Adding Public IP to Nginx Ingress Controller with MetalLB

Static global IP on GKE using Nginx Ingress?

GKE install nginx ingress with static ip and fanout

Nginx Ingress IP Pending on Ubuntu Kubernetes

Nginx does not start: "host not found"

Docker Nginx: host not found in upstream

ingress-nginx - create one ingress per host? Or combine many hosts into one ingress and reload?