[JAVA] Create an HTTPS file server for development with ring-jetty-adapter

Since it was necessary to distribute the file via https during development, check it and make a note of the implementation.

Premise

--Java / Clojure development environment is installed --This time, I used [ring / ring-core" 1.6.2 "]

Make a keystore

By executing the following, you can generate a keystore that contains the public key and private key information required for https.

[Detailed steps](https://www.eclipse.org/jetty/documentation/9.4.x/configuring-ssl.html#generating-key-pairs-and-certificat es)

 keytool -keystore keystore -alias jetty -genkey -keyalg RSA

Ring-middleware to deliver files

Specify to use file middleware that is included in ring as standard. Files under the specified directory can be distributed.

Set up the server for HTTPS

This time, [ring-jetty-adapter](https://github.com/ring-clojure/ring/blob/master/ring-jetty-adapter/src/ring/adapter/jetty. Use clj).

(require '[ring.adapter.jetty :as j]
         '[ring.middleware.file :as rf])

(def jetty
    (j/run-jetty
     (rf/wrap-file identity ;;A handler that does nothing because it only delivers files
                   "." ;;I want to distribute under the project root directory
                   )
     {:host "localhost"
      :http? false ;;Because http is unnecessary
      :ssl? true ;;Enable https
      :ssl-port 9443 ;;Arbitrary value
      :keystore "keystore" ;;Path to the first keystore created
      :key-password "password";;Value used to create the keystore
      :join? false ;;After booting, control returns to the REPL
      }))

Impressions

I used to use the https server module that came with Python, but I was happy because it could be completed easily with Clojure / Java alone.

Recommended Posts

Create an HTTPS file server for development with ring-jetty-adapter
Create an excel file with poi
Create an AWS IoT EduKit development environment with Ubuntu 20.04 + VirtualBox 6.1
Create an app with Spring Boot 2
Create an app catalog site using CLI for Microsoft 365 with Docker
Create an app with Spring Boot
Create a fluentd server for testing
Easy way to create an original logo for your application (easy with your smartphone)
Create a java web application development environment with docker for mac part2
Let's create an instance with .new yourself. .. ..
Create an infinite scroll with Infinite Scroll and kaminari
[Java] Create an executable module with Gradle
Create a jar file with the command
Create Spring Boot-gradle-mysql development environment with Docker
I made an eco server with scala
Create an or search function with Ransack.
Create a Docker container for your development web server in Ansible on MacOS
How to create an Excel form using a template file with Spring MVC
Create an RSA encryption-enabled JSON API with wicket
Create an extension for Burp. ~ Simply add tab ~
Create related data together with FactoryBot for yourself
Rails6.0 ~ How to create an eco-friendly development environment
Create an EC site with Rails5 ⑤ ~ Customer model ~
Create an Annotator that uses kuromoji with NLP4J [007]
[Swift] Create an image selection UI with PhotoKit
Create a web api server with spring boot
[First team development ②] Build an environment with Docker
Create an EC site with Rails 5 ⑩ ~ Create an order function ~
Create a Spring Boot development environment with docker
Create Spring Cloud Config Server with security with Spring Boot 2.0