强制我的heroku应用程序使用SSL(https) [英] Force my heroku app to use SSL (https)

查看:167
本文介绍了强制我的heroku应用程序使用SSL(https)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Heroku上成功运行了一个节点应用程序。我已经购买了加急SSL证书,一切正常。我转到https ...并获得一个完整的绿色栏,证明该网站正在通过https提供

I have a node app running successfully on Heroku. I have purchased an Expedited SSL certificate and it all works fine. I go to https... and get a full 'green bar' proving the site is being served over https

但是,非SSL标准http仍然可用。如何强制应用程序通过https提供服务?谢谢

However, the non-SSL standard http is still available too. How can I force the app to serve over https? Thanks

推荐答案

如果请求到来,您需要向Node.js应用添加代码以将请求重定向到HTTPS版本来自HTTP。

You need to add to the Node.js app the code to redirect the request to the HTTPS version if the request comes from HTTP.

根据您使用的框架或工具,这个想法很简单:

Depending on the framework or the tools you use, the idea is simple:


  • 检查请求方案

  • 如果http,重定向到https传递相同的请求uri和查询

这篇关于强制我的heroku应用程序使用SSL(https)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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