【问题标题】:How to stop mixed Content browser Error when calling App Engine Flexible Environment API?调用 App Engine Flexible Environment API 时如何停止混合内容浏览器错误?
【发布时间】:2017-07-29 07:28:02
【问题描述】:

我在浏览器中收到此错误:

Mixed Content: The page at 'https://{my-site}' was loaded over HTTPS, but 
requested an insecure XMLHttpRequest endpoint 'http://{my-api}'. This request 
has been blocked; the content must be served over HTTPS.

我知道我需要以某种方式允许 https。该应用程序使用 Gunicorn 在自定义 Google App Engine 柔性环境中运行该应用程序。它也使用烧瓶。这是我的 app.yaml:

runtime: custom
env: flex
service: flex-module
entrypoint: gunicorn -b :$PORT main:app

是否可以更改可扩展服务代理中的某些设置以在 App Engine 中允许 https?或者我是否需要获取 ssl 证书和密钥并将以下内容添加到我的 app.yaml:

gunicorn -w3 --certfile=server.crt --keyfile=server.key test:app

我也不确定是否需要将其添加到gunicorn.conf.py,如this documentation

forwarded_allow_ips = '*'
secure_scheme_headers = {'X-APPENGINE-HTTPS': 'on'}

谢谢

【问题讨论】:

    标签: google-app-engine gunicorn app-engine-flexible


    【解决方案1】:

    documentation 中所述,Google 不会为在 appspot.com 上托管的双通配符域颁发 SSL 证书:

    注意:Google 建议使用 HTTPS 协议向您的应用发送请求。 Google 不会为在 appspot.com 上托管的双通配符域颁发 SSL 证书。因此,HTTPS 请求必须使用字符串“-dot-”作为 URL 表示法,而不是“.”。用于分离子域。您可以使用简单的“。”带有您自己的自定义域和其他 HTTP 地址的 URL 表示法。有关详细信息,请参阅以下部分中的 HTTP 和 HTTPS 示例。

    所以为了允许通过 https 的 API 请求并避免混合内容浏览器错误,而不是 http://version-one.my-app.appspot.com,我需要将请求发送到:https://version-one-dot-my-app.appspot.com

    【讨论】:

      【解决方案2】:

      要进行 HTTPS 调用,请通过将以下配置添加到 app.yaml 文件来为您的应用启用 ssl 库:

      libraries:
      
      • 名称:ssl 版本:最新

      https://google-auth.readthedocs.io/en/latest/user-guide.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-12-04
        • 2013-06-16
        • 2018-06-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-30
        相关资源
        最近更新 更多