Need to specify external ip in proxy_pass instead of localhost/127.0.0.1 -How to fix this?

by Traubenfuchs   Last Updated August 15, 2019 14:00 PM

I have a Google Compute Engine instance running with Debian 10 and nginx. Using proxy_pass to pass calls from the frontend to the backend I have

location /api/ {
  proxy_pass http://123.123.123.123:8080;
}

This works. But I am currently not using a fixed IP and thus don't want to hardcode the external IP (123.123.123.123) here. If I replace the external IP in this proxy_pass declaration with localhost or 127.0.0.1, it does not work: The browser receives 502 Bad Gateway when calling /api/.

I can ping localhost and 127.0.0.1 from the console.

Interestingly, I have the same problem with mysql. I need to supply my backend application with the servers external IP address for it to be able to access mysql.

What am I doing wrong here?



Related Questions




Unable to ssh to GCE: "Permission denied (publickey)"

Updated November 11, 2017 03:00 AM