使用Google Compute Engine作为Google App Engine网络应用程序的代理 [英] Using Google Compute Engine as a proxy for a Google App Engine web app

查看:261
本文介绍了使用Google Compute Engine作为Google App Engine网络应用程序的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google App Engine上有一个Java Web应用程序,它向外部API发出请求。 API最近需要将IP地址列入白名单才能访问其服务。因为GAE不提供静态IP地址,所以我知道一种解决方案是设置GCE实例(使用静态IP)并将其用作GAE应用程序发出的外部请求的代理。



我已经使用Debian GNU / Linux 9设置了一个f1-micro实例,并且已经根据文档



如何安装nginx并设置GAE将请求路由到GCE代理?

解决方案

我们遇到类似的问题,需要我们的IP地址被列入白名单。我们通过以下方式解决了这个问题:


  1. 使用静态IP地址分配计算引擎。这是我们提供给客户端的IP地址

  2. 计算引擎上的Installed Squid( https://help.ubuntu.com/lts/serverguide/squid.html
  3. 然后,我们重定向了所有来自App Engine通过代理服务器。您没有列出您正在使用的语言,但是对于PHP,这意味着将以下两行添加到我们的CURL操作中:
    $ b 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']);


    这取决于你所拨打的电话数量,微型实例可能不适合你。我们最初在微型盒子上设置了我们的代理服务器,但不得不每隔几天重新启动一次。我们最终转向了一个标准盒子,并没有遇到任何问题。


    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 services. Because GAE does not offer static IPs, I understand that one solution is to set up GCE instance (with a static IP) and use it as a proxy for external requests made by the GAE app.

    I have set up a f1-micro instance with Debian GNU/Linux 9, and have created a static external IP address as per the documentation.

    How do I install nginx and set up GAE to route requests to the GCE proxy?

    解决方案

    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.

    这篇关于使用Google Compute Engine作为Google App Engine网络应用程序的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆