【发布时间】:2021-01-10 22:34:16
【问题描述】:
我想在 Google App Engine 上启动一个网络应用程序。
它是一个带有前端和后端的 NodeJs/Angular 应用程序,我按照本指南将其部署为单独的服务:https://medium.com/@rgoyard/how-to-deploy-a-single-page-application-and-its-backend-to-google-app-engine-353ff93bd38c 使用 client.yml 部署前端,api.yml 用于后端,dispatch.yml 用于路由所有请求到 /api 到后端服务。
我还在应用中添加了一个自定义子域,并让 SSL 证书由 google 管理。
现在唯一要做的就是强制 SSL,所以当我访问 http://subdomain.domain.com 时,我会自动重定向到 https://subdomain.domain.de。在谷歌创建的标准 apppot 域上一切正常。
现在我尝试了很多方法来解决这个问题,我不知道应用程序是在标准环境还是弹性环境中运行,所以尝试了我找到的所有方法。
文档说对于标准环境,您应该在 app.yml 中使用 secure: always,就像在这个问题 Google App Engine - Redirect HTTP to HTTPS 中一样。它不起作用,这就是我的配置方式:
runtime: python27
api_version: 1
threadsafe: true
service: default
handlers:
- url: /
static_files: immocheck/index.html
upload: immocheck/index.html
- url: /
static_dir: immocheck
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
然后我尝试按照这个答案 https://stackoverflow.com/a/49370832/14021965 配置 nginx-app.conf 但它没有用:
set $test "";
if ($http_x_forwarded_proto = 'http') {
set $test "http";
}
if ($test = 'http') {
return 301 https://$host$request_uri;
}
然后我想也许我在一个灵活的环境中,即使我认为我是标准的。所以我在文档中发现了一些关于使用头盔包的信息,并按照这个非常详细的答案来实现它:https://stackoverflow.com/a/51689825/14021965
很遗憾,这也不起作用,现在我很感谢您的帮助。
提前致谢
【问题讨论】:
标签: node.js angular google-app-engine ssl