<p>I'm a k8s newbie and I am trying to expose a port from the cluster into the local network.
I've tried to do it with metallb config layer2 + load balancer controller and this runs ok.</p>
<p>I have set up a 3-node environment with kubespray.
((192.168.0.1[5,6,7]))</p>
<p>However, I'm trying to expose an api with NodePort and NGINX-Ingress. The nodeport api service is running ok (i can make successfull requests via NODE_IP:NODE_nodeport). But if I try this ingress configuration it justs keeps telling me &quot;connection refused&quot;:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-api
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
spec:
  rules:
  - host: &quot;k8s.customhostname.com&quot; # solves to 192.168.0.17 which has a running pod with the api.
    http:
      paths:
      - path: /test
        pathType: Prefix
        backend:
          service:
            name: svc-api
            port:
              number: 8080
</code></pre>
<p>Then i check the services:</p>
<pre><code>Name:              svc-smouapimapes
Namespace:         smouapi
Labels:            app=apimapes
Annotations:       &lt;none&gt;
Selector:          app=apimapes
Type:              ClusterIP
IP:                10.233.26.225
Port:              springboot  8080/TCP
TargetPort:        8080/TCP
Endpoints:         10.233.90.4:8080,10.233.92.8:8080
Session Affinity:  None
Events:            &lt;none&gt;
</code></pre>
<p>And then check the ingress:</p>
<pre><code>Name:             ingress-smouapimapes
Namespace:        smouapi
Address:          192.168.0.17
Default backend:  default-http-backend:80 (&lt;error: endpoints &quot;default-http-backend&quot; not found&gt;)
Rules:
  Host                     Path  Backends
  ----                     ----  --------
  k8s.nexusgeografics.com
                           /test   svc-smouapimapes:8080   10.233.90.4:8080,10.233.92.8:8080)
Annotations:               nginx.ingress.kubernetes.io/ssl-redirect: false
Events:                    &lt;none&gt;
</code></pre>
<p>Whenever i call :</p>
<pre><code>curl -I http://k8s.nexusgeografics.com/test
# CONNECTION REFUSED
</code></pre>
<p>What am I doing wrong?
Thanks</p>

Enin Kaduk
<p>Try adding the following in the Nginx config ingress-smouapimapes.
Add annotation :</p>
<pre><code>nginx.ingress.kubernetes.io/rewrite-target: /$2
</code></pre>
<p>And instead of this  <code>path: /test</code>  add  <code>path: /test(/|$)(.*)</code></p>
