Google App Engine Flex 在添加云端点后抛出 502

Google App Engine Flex Throws 502 After adding Cloud Endpoints

我在 App Engine Flex 上有一个应用程序 运行(Google Go 运行时,在 docker 运行时有几个额外的文件)。它运行良好,没有任何问题。

然后我添加了 Google Cloud Endpoints,突然间我的每个请求都收到 502,既直接转到应用程序又通过 Cloud Endpoints。

登录实例,nginx-proxy 本身似乎在抛出错误。

Downloading Endpoints Service Configuration to /etc/nginx/endpoints/service.json
curl: (22) The requested URL returned error: 403 Forbidden
Failed to obtain Endpoints Service Configuration from Service Management API
/sbin/start-stop-daemon: warning: failed to kill 26: No such process

app.yaml 的唯一补充是

endpoints_api_service:
   name: "redacted.appspot.com"
   config_id: "2017-06-01r0"

我是 运行 最新版本的 gcloud。我在部署 openapi.yaml 文件时收到 403 forbidden,然后我更新到最新的 gcloud 解决了这个问题。不确定这是否相关。

有人以前遇到过这个吗?

从 Cloud Console UI,你能仔细检查一下你的项目是否启用了 "Google Service Management API" 吗?

如果已启用,您可以通过 SSH 连接到您的 Flex 虚拟机,并通过以下方式获取访问令牌:

curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token

然后你可以使用这个URL来检查它的作用域

https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=

原来核心问题是我第一次用来上传 google 云端点的 gcloud 版本允许我使用不受支持的参数(文件)。切换到通配符后,一切正常。