<p>I am new to kubernetes and I have minikube setup on my linux mint 20.
I am trying to implement server side rendering with nextjs, I have installed ingress-nginx using helm.</p>
<p>ingess-service.yaml :</p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
spec:
  rules:
    - host: example.dev
      http:
        paths:
          - backend:
              serviceName: users-srv
              servicePort: 4000
            path: /api/users/?(.*)

          - backend:
              serviceName: ui-srv
              servicePort: 3000
            path: /?(.*)
</code></pre>
<p>in next js app <code>ui</code> I want to access ingress controller in order to make api calls from server side. I tried:</p>
<p><code>axios.get('http://ingress-nginx-controller-admission/api/users/currentuser')</code></p>
<p><code>axios.get('http://ingress-nginx-controller/api/users/currentuser')</code></p>
<p><code>axios.get('http://ingress-service/api/users/currentuser')</code></p>
<p>but nothing is working.</p>
<p>kubctl get services:</p>
<pre><code> NAME                                 TYPE           CLUSTER-IP       EXTERNAL-IP     PORT(S)                      AGE 
ingress-nginx-controller             LoadBalancer   10.107.45.123    172.42.42.100   80:31205/TCP,443:32568/TCP   80m 
ingress-nginx-controller-admission   ClusterIP      10.111.229.112   &lt;none&gt;          443/TCP                      80m 
kubernetes                           ClusterIP      10.96.0.1        &lt;none&gt;          443/TCP                6d1h 
ui-srv                               ClusterIP      10.99.20.51      &lt;none&gt;          3000/TCP                     89s 
users-mongo-srv                      ClusterIP      10.103.187.200   &lt;none&gt;          27017/TCP              89s 
users-srv                            ClusterIP      10.99.15.244     &lt;none&gt;          4000/TCP                     89s
</code></pre>
<p>can anyone help me out ?
Thanks in advance...</p>

Akshay Patil
<p>The ingress is designed to handle external traffic to the cluster and as such, it is expecting the request to arrive at the domain you specified (aka example.dev)</p>
<p>To access your APIs from inside a Pod, you should most definitely use directly the services that are served by the Ingress, such as <code>users-srv</code> or <code>ui-srv</code>.</p>
<p>If you really want to contact the ingress instead of the Service, you could try a couple things:</p>
<ul>
<li><p>Make so that <code>example.dev</code> points to the LoadBalancer IP address, for example adding it to <code>/etc/hosts</code> of the cluster's nodes should work 8or even internally in the Pod). But take into consideration that this means accessing the services by a long route when you could just access them with the service name.</p>
</li>
<li><p>Remove the host parameter from your rules, meaning the services should be served generally at the IP address of the nginx-controller, this should make using <code>ingress-nginx-controller</code> work as expected. This is not supported by all Ingress Controllers but it could work.</p>
</li>
</ul>
