I started a very simple login and signup app with MongoDB. I got the website working on google cloud but I couldn't set the api request correctly. I am getting 502 bad gateway from nginx. the website is on: http://35.188.82.6 and the github repo is on: https://github.com/damonleelcx/PureSign
2020/10/11 23:44:23 [error] 451#451: *1143751 connect() failed (111: Connection refused) while connecting to upstream, client: 10.128.0.4, server: _, request: "POST /api/users/register HTTP/1.1", upstream: "http://10.0.2.43:3000/api/users/register", host: "35.188.82.6", referrer: "http://35.188.82.6/"
2020/10/11 23:44:23 [error] 451#451: *1143751 connect() failed (111: Connection refused) while connecting to upstream, client: 10.128.0.4, server: _, request: "POST /api/users/register HTTP/1.1", upstream: "http://10.0.1.48:3000/api/users/register", host: "35.188.82.6", referrer: "http://35.188.82.6/"
2020/10/11 23:44:23 [error] 451#451: *1143751 connect() failed (111: Connection refused) while connecting to upstream, client: 10.128.0.4, server: _, request: "POST /api/users/register HTTP/1.1", upstream: "http://10.0.0.80:3000/api/users/register", host: "35.188.82.6", referrer: "http://35.188.82.6/"
10.128.0.4 - - [11/Oct/2020:23:44:23 +0000] "POST /api/users/register HTTP/1.1" 502 552 "http://35.188.82.6/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" 546 0.004 [default-server-cluster-ip-service-3000] [] 10.0.2.43:3000, 10.0.1.48:3000, 10.0.0.80:3000 0, 0, 0 0.003, 0.001, 0.000 502, 502, 502 1c28cfe67d44718379c08c826559df90
10.0.0.1 - - [11/Oct/2020:23:51:56 +0000] "GET / HTTP/1.1" 200 993 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7" 189 0.002 [default-client-cluster-ip-service-8080] []
10.0.2.44:8080 993 0.003 200 875335eee9ecf00b0140ac95af93d3d6"http://10.0.x.xx:3000/api/users/register" is not matching my server ip "35.188.82.6". BTW, my express server is listening on localhost.
Please help~~~ Thanks!!!
503 indicates that there is an issue with server/pod not being able to handle the request (usually due to server being overloaded or down).
Ingress -> Service --(Place where the communication issue exists)--> PodSo your problem lies withing server (expressjs) configuration. The localhost argument here is optional.
Once you remove it, server will then listen on all of the interfaces. This will allow you to get your traffic towards pod.