How do you enable https and http->https redirects in ring / compojure

五迷三道 提交于 2019-12-01 03:17:43

问题


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.


回答1:


Its very simple. If you want to enable HTTPS support in your web app, just do the following:

  1. Generate a Java KeyStore(.jks) file using a linux tool called keytool.
  2. In the ring map of your project.clj file, add the following:

    { :ssl? true :ssl-port 8443 :keystore "path to the jks file" :key-password "the keystore password" }

  3. Fire up the server. Now your web app is HTTPS enabled.

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.




回答2:


It's possible to serve HTTPS with clojure, but it's much more popular to put nginx or something like that in front of your ring server. If you can figure out how to configure jetty, though, run-jetty clearly supports SSL.



来源:https://stackoverflow.com/questions/18432832/how-do-you-enable-https-and-http-https-redirects-in-ring-compojure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!