aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Barksdale <amatus.amongus@gmail.com>2012-04-04 20:56:29 -0500
committerDavid Barksdale <amatus.amongus@gmail.com>2012-04-04 20:56:29 -0500
commit9b6b81032e6114687aa89339c63cc23962844767 (patch)
tree319c0fb1e0ee901c12ebcea64ad02be86868adde /src
parent1e07ad99d2947a877aafd43c2d9215f862db16aa (diff)
Configure https.
Diffstat (limited to 'src')
-rw-r--r--src/ctf_website/server.clj14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ctf_website/server.clj b/src/ctf_website/server.clj
index 876e836..95e5309 100644
--- a/src/ctf_website/server.clj
+++ b/src/ctf_website/server.clj
@@ -3,9 +3,23 @@
(server/load-views "src/ctf_website/views/")
+(defn redirect-https
+ [handler]
+ (fn [request]
+ (if (= :http (:scheme request))
+ (ring.util.response/redirect
+ (str "https://" (:server-name request) (:uri request)))
+ (handler request))))
+
+(server/add-middleware redirect-https)
+
(defn -main [& m]
(let [mode (keyword (or (first m) :dev))
port (Integer. (get (System/getenv) "PORT" "80"))]
(server/start port {:mode mode
+ :jetty-options {:ssl? true
+ :ssl-port 443
+ :keystore "/home/ctf/ctf-website/key_crt.jks"
+ :key-password "password"}
:ns 'ctf-website})))