diff options
-rw-r--r-- | key_crt.jks | bin | 0 -> 1323 bytes | |||
-rw-r--r-- | src/ctf_website/server.clj | 14 |
2 files changed, 14 insertions, 0 deletions
diff --git a/key_crt.jks b/key_crt.jks Binary files differnew file mode 100644 index 0000000..aa7d0bb --- /dev/null +++ b/key_crt.jks 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}))) |