This is a simple example webserver written using java 20, using Jetty embedded server (version 11).
This should be a good starting point for implementing a webservice in java.
Features:
- HTTPS, with TLS certificates loading from
res/self_signed.keystore
- Serves directory
/.well-known/acme-challenge/
to complete acme-challenge with webroot approach (to avoid downtime running certbot in standalone). - Builds with maven and stages distribution in
dis/
withcompile-distribution.ps1
- Blazingly fast
- Build with maven
- Inside
res/
runkeytool -genkey -keyalg RSA -alias self_signed -keystore self_signed.keystore -storepass my_password123 -dname "CN=127.0.0.1" -noprompt
in order to get a keystore - Run Main.java
- Build with maven
- Run
compile-distribution.ps1
- Copy your keystore to
dis/webapp/res/
- Copy
dis/webapp/
to your production server - Run
simple-jetty-example-tls.jar
in your preferred way (could be systemd) - (Optional) Configure nginx to expose your service to the internet trough port 443
- (Optional) Replace keystore with one generated using certificates from certbot and letsencrypt
You can do with this as you want.