title: Error 502 when accessing backend inside same cluster in Kubernetes
body: <p>Backend: python (Django)
  Frontend: angular6</p>
  
  <p>I just deployed my backend and frontend on same cluster in Google Kubernetes. They are two individual services inside same cluster. The pods on the clusters look like:</p>
  
  <pre><code>NAME                               READY     STATUS    RESTARTS   AGE
  backend-f4f5df588-nbc9p     1/1       Running   0          1h
  frontend-85885799d9-92z5f   1/1       Running   0          1h
  </code></pre>
  
  <p>And the service looks like:</p>
  
  <pre><code>NAME              TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)          AGE
  backend    LoadBalancer   10.3.249.148   35.232.61.116    8000:32291/TCP   26m
  frontend   LoadBalancer   10.3.248.72    35.224.112.111   8081:31444/TCP   3m
  kubernetes        ClusterIP      10.3.240.1     &lt;none&gt;           443/TCP          1h
  </code></pre>
  
  <p>My backend just works on the django server, starting by using <code>python manage.py runserver</code> command, everything works fine. I built the frontend and deployed on Nginx server. So there're two Docker images, one for django, one for nginx, as two pods in cluster. </p>
  
  <p>Then there're two ingress for both of them. Exposing 80 port for frontend and 8000 for backend. Holding on the load balancer nginx controller. After assigning a domain, I can visit <a href="https://abc/project" rel="nofollow noreferrer">https://abc/project</a> as front end. But when I want to make API requests, ERR 502 appears. The error message in nginx is: </p>
  
  <pre><code>38590 connect() failed (111: Connection refused) while connecting to upstream, client: 163.185.148.245, server: _, request: "GET /project/api HTTP/1.1", upstream: "http://10.0.0.30:8000/dataproject/api", host: "abc" 
  </code></pre>
  
  <p>The upstream in error message is the correct IP for the backend service, but still gets a 502 error. I can curl from nginx server to frontend. But cannot cur to backend. Any help?
  PS. Everything works fine before deployment.</p>