简体   繁体   English

连接到Google Compute Engine代理服务器时,“ Google App Engine不支持使用代理”错误

[英]'Google App Engine does not support the use of proxies' error when connecting to Google Compute Engine proxy server

We have a Java 7 Google App Engine instance which we are trying to connect to an external API. 我们有一个Java 7 Google App Engine实例,我们正在尝试将其连接到外部API。 Because the API server requires whitelisted IP addresses for access, we have set up a Google Compute Engine proxy server with Squid installed ( a solution proposed elsewhere ) and then whitelisted the external IP address of the proxy server on the API server. 由于API服务器需要白名单的IP地址才能访问,因此我们已经设置了安装了Squid的Google Compute Engine代理服务器( 在其他地方提出了解决方案 ),然后将API服务器上的代理服务器的外部IP地址列入了白名单。

This way, requests made from GAE will be redirected to GCE first, allowing API calls to be made. 这样,从GAE发出的请求将首先重定向到GCE,从而允许进行API调用。 However, GAE requests are currently failing with the message: 但是,GAE请求当前失败,并显示以下消息:

 WARNING: Google App Engine does not support the use of proxies. 

Can anyone advise a solution? 谁能提供解决方案?

First of all, the Java 7 runtime is deprecated, so you should migrate to the Java 8 version. 首先,不建议使用Java 7运行时,因此您应该迁移到Java 8版本。 You can do it by specifying the Java 8 runtime in the appengine-web.xml file: 您可以通过在appengine-web.xml文件中指定Java 8运行时来实现:

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <runtime>java8</runtime>
  <threadsafe>true</threadsafe>
</appengine-web-app>

There are other features that will change with the migration to Java 8. All the changes are explained here . 随着向Java 8的迁移,其他功能也会发生变化。所有更改都在此处进行了说明。

Just in case the error comes because of some issue in the configuration, please make sure the instance you are using as a proxy is correctly configured (using Squid is ok). 以防万一由于配置中的某些问题而导致错误,请确保正确配置了用作代理的实例(可以使用Squid)。 The firewall rules and access control lists should be correctly established, such as: 防火墙规则和访问控制列表应正确建立,例如:

gcloud compute firewall-rules create [FIREWALL_RULE] --network [NETWORK] --allow tcp:3128

You should also set the proper access control entries by enabling them in the Squid config. 您还应该通过在Squid配置中启用它们来设置适当的访问控制项。 Here are some examples: 这里有些例子:

sudo sed -i 's:#\(http_access allow localnet\):\1:' /etc/squid/squid.conf
sudo sed -i 's:#\(http_access deny to_localhost\):\1:'/etc/squid/squid.conf

If you follow this example you can test the correct use of an instance used as a proxy server. 如果您遵循此示例 ,则可以测试用作代理服务器的实例的正确使用。

There is a static class in Java called ApiProxy ( com.google.apphosting.api ) that can be used as a collection point for all calls from user code to the application server. Java中有一个称为ApiProxy( com.google.apphosting.api )的静态类,可以用作从用户代码到应用程序服务器的所有调用的收集点。 Here you can find all the classes and methods related to it, as well as other classes related to ApiProxy. 在这里,您可以找到与其相关的所有类和方法,以及与ApiProxy相关的其他类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM