<p>I have some problem with my Kubernetes ingress for only this service that always returns 502.
I have tested the service and it's working fine, but when I expose it with ingress it doesn't work.</p>
<p>I use EKS and Nginx ingress controller</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: develop
  name: chatbot-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
spec:
  rules:
    - http:
        paths:
          - backend:
              service:
                name: chatbot
                port:
                  number: 7070
            pathType: Prefix
            path: /
      host: api.example.com
---
apiVersion: v1
kind: Service
metadata:
  name: chatbot
  namespace: develop
spec:
  selector:
    app: chatbot
  ports:
    - port: 7070
      targetPort: 7070
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: chatbot
  namespace: develop
spec:
  selector:
    matchLabels:
      app: chatbot
  template:
    metadata:
      labels:
        app: chatbot
    spec:
      containers:
        - name: chatbot
          image: chatbot 
          imagePullPolicy: Always
          envFrom:
            - secretRef:
                name: chatbot-secret
          ports:
            - containerPort: 7070
</code></pre>
<p>Ingress log</p>
<pre><code>2022/06/16 13:51:20 [error] 2069#2069: *9278411 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.49.139, server: api.example.com, request: &quot;GET / HTTP/2.0&quot;, upstream: &quot;http://192.168.8.148:7070/&quot;, host: &quot;api.example.com&quot;
2022/06/16 13:51:20 [error] 2069#2069: *9278411 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.49.139, server: api.example.com, request: &quot;GET / HTTP/2.0&quot;, upstream: &quot;http://192.168.8.148:7070/&quot;, host: &quot;api.example.com&quot;
</code></pre>

Vivid
<p>Should that host be updated from api.example.com to the relevant endpoint of the service to connect to?</p>
<pre><code>spec:
  rules:
    - http:
        paths:
          - backend:
              service:
                name: chatbot
                port:
                  number: 7070
            pathType: Prefix
            path: /
      host: api.example.com
</code></pre>
<p>Something that might help is using a service like Lumigo to do some tracing (they have a free tier)</p>
