GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - schnatterer/letsencrypt-tomcat: Tomcat that automatically fetches certificates via letsencrypt

BranchesTags
Open more actions menu

Latest commit

 

History

24 Commits
24 Commits

Folders and files

NameName
Last commit message
Last commit date
etc/dehydrated
etc/dehydrated
 
 
examples
examples
 
 
hooks
hooks
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
meta-entrypoint.sh
meta-entrypoint.sh
 
 

Repository files navigation

Let's encrypt Tomcat!

Showcase Tomcat Docker Image that automatically fetches and renews certificates via letsencrypt.

Uses

  • dehydrated to manage certs,
  • tomcat-reloading-connector for reloading images without restarting tomcat.
  • and either
    • bitmai's Tomcat Docker image or
    • spring-boot.

Try out by running examples.

Build your own image

The building blocks are conveniently packaged into a docker image: schnatterer/letsencrypt-tomcat. This image is neither intended to be used as base image nor to be run itself. It's a mere container were you can copy the components needed for your app.

It contains the following directories:

  • /letsencrypt necessary for all apps:
    • dehydrated for cert retrival
    • dumb-init for properly handling your main process and the certificate process
    • meta-entrypoint.sh for launching the processes
  • [/tomcat-reloading-connector](https://github.com/schnatterer/tomcat-reloading-connector) necessary for standalone tomcat instances, so they can reload the certificate at runtime
    See standalone example.
  • /lib - pre-compiled version of Apache Portable Runtime (APR) and JNI wrappers for APR used by Tomcat (libtcnative).
    Requires glibc and openssl (works with debian images, for example).
    For other libc libraries see here for compiling your own APR libs. See spring-boot example or embedded tomcat example.

So in your Dockerfile just copy what you need as shown in examples. For the whole process to work, your container requires the following packages:

  • bash,
  • openssl and
  • curl

Your tomcat server must be configured to

  • serve static content from /static/.well-known/acme-challenge on http://${DOMAIN}/static/.well-known/acme-challenge in order for to be able to answer to the letsencrypt challenges,
  • serve traffic via port 80 (externally), in order to succeed in letsencrypt's http-01 challenge,
  • respond with HTTP return code less than 400, on http://localhost:${LOCAL_HTTP_PORT}/ (default port 8080).

If successful, the certificate files will be stored here:

  • Certificate file: /certs/${DOMAIN}/cert.pem
  • Certificate private key file: /certs/${DOMAIN}/privkey.pem
  • Certificate chain file: /certs/${DOMAIN}/fullchain.pem

Configuration at runtime

  • Mandatory: Env var DOMAIN that passes the TLD to be used for requesting certificates for
  • Optional Env vars:
    • LOCAL_HTTP_PORT - (default 8080). Once this (internal) port is ready to receive traffic, the certificate challenge will begin.
    • STAGING - If set to true creates certs against letsencrypt staging, which has no rate limit but is not accepted by your browser.
    • ENABLE_LETSENCRYPT - if set to false the letsencrypt process is not started
    • CREATE_SELFSIGNED - if set to false no selfsigned certifcate is generated at start up.
      Depending on your setup this might result in failing startup of the tomcat connectors
  • Persistence: Your certs are stored inside your container at CERT_DIR (default: /certs/), so you might want to persist this folder.

Run Examples

First, make sure to set the DNS record to match your IP address and that port 80 and 443 are available.

Note that:

  • -v... Persists your cert in a volume certs if left out an anonymous volume is used
sudo docker run --rm -it \
  -p80:8080 -p443:8443 \
  -eDOMAIN=example.com \
  -v certs:/certs/ \
  -eSTAGING=true \
  schnatterer/letsencrypt-tomcat:standalone
# or
# schnatterer/letsencrypt-tomcat:spring-boot
# schnatterer/letsencrypt-tomcat:embedded-tomcat

Building

# First build the base image ( packages the building blocks for letsencrypt tomcat)
docker build -t schnatterer/letsencrypt-tomcat .
# Build the examples 
docker build -t schnatterer/letsencrypt-tomcat:standalone --file=examples/standalone/Dockerfile .
docker build -t schnatterer/letsencrypt-tomcat:spring-boot --file=examples/spring-boot/Dockerfile .
docker build -t schnatterer/letsencrypt-tomcat:embedded-tomcat --file=examples/embedded-tomcat/Dockerfile .

About

Tomcat that automatically fetches certificates via letsencrypt

Topics

dehydrateddockerletsencrypttlstomcat

Resources

Readme
MIT license
Activity

Stars

4 stars

Watchers

2 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.