Using Google Compute Engine as a proxy for a Google App Engine web app

前端 未结 2 933
梦毁少年i
梦毁少年i 2020-12-06 18:34

I have a Java web app on Google App Engine which makes requests to an external API. The API recently requires the whitelisting of IP addresses in order to access its service

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 18:51

    We faced a similar issue with a client who needed our IP address to be whitelisted. We solved the issue by:

    1. Spinning up a Compute Engine with a static IP address. This is the IP address we gave to our client
    2. Installed Squid on the compute engine (https://help.ubuntu.com/lts/serverguide/squid.html)
    3. We then redirected all calls from the App Engine through the proxy server. You didn't list what language you are using but for PHP, that meant adding the following two lines to our CURL operations:

      curl_setopt($ch, CURLOPT_PROXY, "http://" . $_SERVER['SQUID_PROXY_HOST'] . ":" . $_SERVER['SQUID_PROXY_PORT'] );

      curl_setopt($ch, CURLOPT_PROXYUSERPWD, $_SERVER['SQUID_PROXY_USER'] . ":" . $_SERVER['SQUID_PROXY_PWD']);

    One thing to note is that depending on the number of calls you are making, a micro instance might not work for you. We initially setup our proxy server on a micro box but were having to restart it every few days. We ended up switching to a standard box and have not run into any problems since.

提交回复
热议问题