如何在ring / compojure中启用https和http-> https重定向 [英] How do you enable https and http->https redirects in ring / compojure
问题描述
我正在开发一个RESTful应用程式,我需要将来自http地址的要求重新导向至与https相同的地方。我似乎无法启用https使用ring / compojure。
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:
- 生成Java KeyStore
- 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? true
:ssl-port 8443
:keystorejks文件的路径
: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屋!