<p>ingress ip is providing expected result but host returns <strong>404 http not found</strong></p>
<p>Ingress.yaml</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: helloworld-ing
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot; 
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot; 
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  defaultBackend:
    service:
      name: helloworld-svc
      port:
        number: 8080
  ingressClassName: nginx
  tls:
    - hosts:
        - helloworld.dev.com
      secretName: ingress-tls-csi
  rules:
    - host: helloworld.dev.com
      http:
        paths:
          - path: /helloworld
            pathType: Prefix
            backend:
              service:
                name: helloworld-svc
                port:
                  number: 8080
</code></pre>
<p>Ingress Ip was not working earlier but adding default backend resolved that issue.
I believe this can be the issue that its not going past backend and not even reaching rules.</p>
<p>I do not see warning/errors in ingress logs but If I remove default backend I can not even access app using ingress IP.</p>
<p>I am not sure what I am missing in my ingress configuration.</p>
<p>I am trying same path for url and Ip -</p>
<pre><code>Curl http://10.110.45.61/helloworld/service/result

Curl http://helloworld.dev.com/helloworld/service/result
</code></pre>
<p>I am happy to provide more information if required.</p>

megha
<p>Hello, Hope you'are enjoying your Kubernetes journey !</p>
<p>So This is what I have tested for a first try (i havent tested tls now):
First I have setup a kind cluster locally with this configuration (info here: <a href="https://kind.sigs.k8s.io/docs/user/quick-start/" rel="nofollow noreferrer">https://kind.sigs.k8s.io/docs/user/quick-start/</a>):</p>
<pre><code>kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: so-cluster-1
nodes:
- role: control-plane
  image: kindest/node:v1.23.5
- role: control-plane
  image: kindest/node:v1.23.5
- role: control-plane
  image: kindest/node:v1.23.5
- role: worker
  image: kindest/node:v1.23.5
- role: worker
  image: kindest/node:v1.23.5
- role: worker
  image: kindest/node:v1.23.5
</code></pre>
<p>after this I create my cluster with this command:</p>
<pre><code>kind create cluster --config=config.yaml
</code></pre>
<p>Next, i have created a test namespace (manifest obtained with: kubectl create ns so-tests -o yaml --dry-run):</p>
<pre><code>apiVersion: v1
kind: Namespace
metadata:
  name: so-tests
</code></pre>
<p>then I created this vanilla nginx deployment and exposed it with a service, here is the config (manifest from here <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment</a>):</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
</code></pre>
<p>same with the pod (manifest from obtained with: k expose deployment nginx-deployment --dry-run -o yaml ):</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: nginx
  name: nginx-deployment
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
</code></pre>
<p>after applying every manifests to my cluster and checked if my pods were running, I made sure that i could access my nginx pod web homepage by running:</p>
<pre><code>kubectl port-forward pod/nginx-deployment-74d589986c-c85r9 8080:80 #checked on localhost:8080 and it was succesful
</code></pre>
<p>I've done the same against the service to make sure that it was correctly redirecting the traffic to the pod:</p>
<pre><code>k port-forward service/nginx-deployment 8080:80 #checked on localhost:8080 and it was succesful
</code></pre>
<p>When I was sure that my workload was correctly running and accessible, I installed nginx ingress controller (from here: <a href="https://kubernetes.github.io/ingress-nginx/deploy/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/deploy/</a>) with this command:</p>
<pre><code>helm upgrade --install ingress-nginx ingress-nginx \
  --repo https://kubernetes.github.io/ingress-nginx \
  --namespace ingress-nginx --create-namespace
</code></pre>
<p>Then I created the ingress k8s resource, here is the config (obtained by running: k create ingress demo-localhost --class=nginx --rule=&quot;demo.localdev.me/*=demo:80&quot; and by replacing the service.name by the name of my service.):</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  creationTimestamp: null
  name: demo-localhost
spec:
  ingressClassName: nginx
  rules:
  - host: demo.localdev.me
    http:
      paths:
      - backend:
          service:
            name: nginx-deployment
            port:
              number: 80
        path: /
        pathType: Prefix
</code></pre>
<p>Then to check if my ingress was corretly redirecting the traffic i ran:</p>
<pre><code>kubectl port-forward --namespace=ingress-nginx service/ingress-nginx-controller 8080:80 #I also tested this on my browser localhost:8080
</code></pre>
<p>And guess what? -&gt; 404 not found.</p>
<p>so, I decided to replace the name &quot;demo.localdev.me&quot; by &quot;localhost&quot; and it worked, here is the conf:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: demo-localhost
spec:
  ingressClassName: nginx
  rules:
  - host: localhost #demo.localdev.me
    http:
      paths:
      - backend:
          service:
            name: nginx-deployment
            port:
              number: 80
        path: /
        pathType: Prefix
</code></pre>
<p>I went to my  C:\Windows\System32\drivers\etc\hosts file on windows (equivalent to /etc/hosts on linux, or equivalent to your DNS serveur in enterprise) to check if it was a dns issue, i added this line:</p>
<pre><code>127.0.0.1       demo.localdev.me
</code></pre>
<p>and it worked as expected. (make sure to clear you browser cache when playing with /etc/hosts file or to use private navigation to get accurate resulsts)</p>
<p>So, you can do some testing: make sure that:</p>
<ol>
<li>your path is correctly reachable (you can do the testing with
kubectl port-forward, as i have done before)</li>
<li>you do have the correct entry in dns that redirects the traffic to your nginx service (not your application pod service)</li>
<li>you do not have a firewall that is blocking your ports</li>
<li>the tls configuration is working properly (try with and without)</li>
</ol>
<p>If you have more information to share with us, feel free, i'll be happy to help you !</p>
<p>Have a nice day man !</p>
