【问题标题】:Google App Engine: 404 Not Found with Custom DomainGoogle App Engine:自定义域未找到 404
【发布时间】:2018-07-04 20:38:38
【问题描述】:

我在 Google App Engine 上将 Flask 应用设置为 Flex 项目。 当我浏览到 https://{project-id}.appspot.com 时,一切正常,我可以毫无问题地使用该应用程序。为什么我会收到 404?

我将自定义域设置为 host.mydomain.io

gcloud beta 应用域映射列表

ID                     SSL_CERTIFICATE_ID  SSL_MANAGEMENT_TYPE  
host.mydomain.io       5270000             AUTOMATIC

然后我将我的 dns 设置为指向 ghs.googlehosted.com

nslookup host.mydomain.io

Non-authoritative answer:
host.mydomain.io    canonical name = ghs.googlehosted.com.
Name:   ghs.googlehosted.com
Address: 172.217.0.115

但是我总是得到 404,这里是日志

gcloud app 日志tail -s default

2018-01-25 03:06:32 default[20180124t211951]  "GET /" 404
2018-01-25 03:06:36 default[20180124t211951]  "GET /" 404

然而,当我使用 https://{project-id}.appspot.com 地址浏览时,它工作正常

2018-01-25 02:31:55 default[20180124t211951]  "GET /" 200

app.yaml

entrypoint: 'gunicorn manage:app -w 4 -b :$PORT'
env: flex
runtime: python
env_variables:
  FLASK_CONFIG: "production"

【问题讨论】:

    标签: google-app-engine


    【解决方案1】:

    我发现问题来自我的 Flask 配置,而不是来自 Google App Engine

    在我的生产配置中,我有这个:

    SERVER_NAME = "{project-id}.appspot.com"
    

    这导致 Flask 返回 404 ,而不是 App Engine。

    改成

    SERVER_NAME = "hostname.mydomain.io"
    

    为我修好了。

    【讨论】:

      猜你喜欢
      • 2012-06-10
      • 2017-04-08
      • 2014-07-05
      • 1970-01-01
      • 1970-01-01
      • 2018-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多