App Engine 柔性版上的 HTTP 到 HTTPS 重定向 [英] HTTP to HTTPS redirection on App Engine Flexible

查看:22
本文介绍了App Engine 柔性版上的 HTTP 到 HTTPS 重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了这个答案:从 http 重定向到https 在谷歌云中,但目前似乎不再准确.引用的锚点 ( https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml#security ) 似乎已被删除,但没有替换说明.

I've followed the answer of this: Redirect from http to https in google cloud but it does not seem to be currently accurate any more. The anchor referenced ( https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml#security ) seems to have been removed but without a note of a replacement.

作为参考,我通过 Google App (flex) 引擎提供 NodeJS.根据我在 app.yaml 中得到的答案:

For reference, I am serving NodeJS over a Google App (flex) Engine. As per the answer I've got in my app.yaml:

handlers:
- url: /.*
  script: IGNORED
  secure: always

由于 HTTPS 在到达我的 Express 引擎之前显然已终止(并且在那里重定向将毫无用处);目前如何正确实施?

Since HTTPS is obviously terminated before it hits my Express engine (and redirection on there would be useless); how is it currently correctly implemented?

可能有用,我通过控制台中的自定义域"选项卡附加了一个外部域,并且确实配置了 SSL 证书(因此,如果用户手动访问 https://.com,一切正常)

Potentially helpful, I have an external domain attached via the "Custom domains" tab in the console, and there is indeed a SSL certificate configured (so if a user manually goes to https://.com everything is fine)

推荐答案

柔性环境当前不支持 app.yaml 中的处理程序.如果你想要 https://重定向,你有几个选择:

The flexible environment does not current support handlers in the app.yaml. If you want https:// redirection, you have a few options:

  • 使用 helmet 为您处理 HSTS 内容,并实现您自己的初始重定向.
  • 我写了一个快乐的小库,总是在所有路由上强制使用 SSL 来表示 yes-https
  • Use helmet to do to HSTS stuff for you, and implement your own initial redirect.
  • I wrote a happy little library to always forces SSL on all routes for express yes-https

我们正在考虑默认将所有流量自动重定向到 SSL.您认为这对您的应用来说是一件好事吗?

We are considering auto-redirecting all traffic to SSL by default. Do you think that would be a good thing for your apps?

这篇关于App Engine 柔性版上的 HTTP 到 HTTPS 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆