<p>I have following setup in minikube cluster</p>

<ol>
<li>SpringBoot app deployed in minikube cluster</li>
</ol>

<blockquote>
  <p>name : opaapp and containerPort: 9999</p>
</blockquote>

<ol start="2">
<li>Service use to expose service app as below</li>
</ol>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: opaapp
  namespace: default
  labels:
    app: opaapp
spec:
  selector:
    app: opaapp
  ports:
    - name: http
      port: 9999
      targetPort: 9999
  type: NodePort

</code></pre>

<ol start="3">
<li>Created an ingreass controller and ingress resource as below</li>
</ol>

<pre><code>apiVersion: networking.k8s.io/v1beta1 # for versions before 1.14 use extensions/v1beta1
kind: Ingress
metadata:
  name: opaapp-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - host: opaapp.info
    http:
      paths:
      - path: /
        backend:
          serviceName: opaapp
          servicePort: 9999
</code></pre>

<p>I have setup host file as below</p>

<pre><code>172.17.0.2    opaapp.info
</code></pre>

<p>Now, if I access service as below </p>

<p><a href="http://opaapp.info:32746/api/ping" rel="nofollow noreferrer">http://opaapp.info:32746/api/ping</a>  :  I am getting the response back</p>

<p>But if I try to access as </p>

<p><a href="http://opaapp.info/api/ping" rel="nofollow noreferrer">http://opaapp.info/api/ping</a> : Getting 404 error</p>

<p>Not able to find the error on configuration</p>

ajoy sinha
<p>The nginx ingress controller has been exposed via NodePort <code>32746</code> which means nginx is not listening on port 80/443 in the host's(172.17.0.2) network, rather nginx is listening on port 80/443 on Kubernetes pod network which is different than host network. Hence accessing it via  <code>http://opaapp.info/api/ping</code> is not working. To make it work the way you are expecting the nginx ingress controller need to be deployed with <code>hostNetwork: true</code> option so that it can listen on 80/443 port directly in the host(172.17.0.2) network which can be done as discussed <a href="https://stackoverflow.com/questions/56915354/how-to-install-nginx-ingress-with-hostnetwork-on-bare-metal">here</a>.</p>
