Need to specify external ip in proxy_pass instead of localhost/ -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/ {

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

I can ping localhost and 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