我在 Google Domains (www.example.com) 上有一个网站,它由 Gcloud 托管。我按照此处列出的说明设置 SSL 和 https:https://cloud.google.com/appengine/docs/standard/python/securing-custom-domains-with-ssl
基本上,我只是运行了 gcloud beta app domain-mappings update example.com --certificate-management='AUTOMATIC'
现在我确实可以访问https://example.com了和 https://www.example.com .但我也可以访问这些域的不安全 http 版本。
如何将我的 Google 域设置为始终使用 https?如果有人输入 http://example.com ,我希望它转到 https 站点。
记录: 我的裸域 (example.com) 有 4 条 A 记录和 4 条 AAAA 记录。
我的 www.example.com 域有 1 条别名=www 的 CNAME 记录。
最佳答案
您是否尝试过在 app.yaml
的处理程序中设置 secure: always
?
handlers:
- url: /youraccount/.*
script: accounts.app
login: required
secure: always
always
Requests for a URL that match this handler that do not use HTTPS are automatically redirected to the HTTPS URL with the same path. Query parameters are preserved for the redirect
https://cloud.google.com/appengine/docs/standard/python/config/appref#handlers_element
关于google-app-engine - 如何使用自定义域强制执行到 Google App Engine 的 HTTPS 流量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48752601/