Jens Zalzala
Jens Zalzala

Reputation: 2576

What is the equivalent of a hosts file mapping for AppEngine?

Our AppEngine app is connecting to a remote service which requires a VPN and also required me to add entries to the hosts file on my local machine in order to connect to their endpoints. e.g.

10.200.30.150 foo.bar.com

This is working fine when running the app locally, but I can't figure out how to set this up on Google Cloud to work once deployed. I can't use the IP addresses directly because it errors that the IP is not on the cert's list.

How do I map the host names to the IPs in Google Cloud so that AppEngine can use them?

Upvotes: 0

Views: 293

Answers (1)

Happy-Monad
Happy-Monad

Reputation: 2002

From the error mentioned in the comment I suspect connecting directly through the IP fails because the certificate doesn't recognize the IP to DNS mapping as valid and therefore the secure connection setup breaks. Based on the requirements of connecting to the API by VPN and tweaking the hosts mapping there are few things you may try.

The simplest approach that may work would be using a Google Compute Engine VM instance, since there you would able to manipulate the etc/hosts file and replicate the local machine setup. This VM could be used either as the main app service or as a proxy from App Engine to the 3rd party API endpoint. To go that route I would suggest taking a look at these two posts which explain how to change the etc/hosts file on GCE (Changing the file once wouldn't work as the VM periodically overrides it, see the posts for cronjob like workaround).

Separately, as your app runs in App Engine flexible environment there is the chance to provide a docker container with the app packaged. It may be possible to set the workaround above in the docker file and have it working in App Engine too.

Upvotes: 1

Related Questions