如何在 ring/compojure 中启用 https 和 http->https 重定向 [英] How do you enable https and http->https redirects in ring / compojure
问题描述
我正在开发一个 RESTful 应用程序,为此我需要将来自 http 地址的请求重定向到它的 https 等效项.我似乎无法使用 ring/compojure 启用 https.
I am developing a RESTful app, for which I need to redirect requests coming in from an http address to it's https equivalent. I cannot seem to be able to enable https using ring/compojure.
有人有一些有用的教程和/或链接吗?我没有找到.
Anyone have some useful tutorials and/or links? I haven't found any.
文档也没有任何有用的东西.
The documentation doesn't have anything useful either.
推荐答案
很简单.如果您想在您的网络应用中启用 HTTPS 支持,只需执行以下操作:
Its very simple. If you want to enable HTTPS support in your web app, just do the following:
- 使用名为 keytool 的 Linux 工具生成 Java KeyStore(.jks) 文件.
在您的
project.clj
文件的环图中,添加以下内容:
- Generate a Java KeyStore(.jks) file using a linux tool called keytool.
In the ring map of your
project.clj
file, add the following:
{:ssl?真的:ssl 端口 8443:keystore "jks 文件的路径":key-password "密钥库密码"}
{ :ssl? true :ssl-port 8443 :keystore "path to the jks file" :key-password "the keystore password" }
当我尝试使用社交媒体代码测试我的登录时遇到了类似的问题,这显然必须通过 HTTPS 进行身份验证,这对我有用.
I had a similar problem while I was trying to test my Sign-In using Social Media code which obviously had to authenticate over HTTPS and this did the trick for me.
这篇关于如何在 ring/compojure 中启用 https 和 http->https 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!