From 41d2116ee2091e99bf95bf6c21cef416c10effcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mitchell=20B=C3=B6secke?= Date: Wed, 15 Nov 2023 15:47:00 -0700 Subject: [PATCH] Added basic HTTPS support by mounting a JKS file and providing some environment variables. --- Dockerfile | 6 ++ README.md | 12 +++ config/server-https.xml | 181 ++++++++++++++++++++++++++++++++++++++++ startup.sh | 9 ++ 4 files changed, 208 insertions(+) create mode 100644 config/server-https.xml diff --git a/Dockerfile b/Dockerfile index 27de96d..8d2ffab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -96,7 +96,13 @@ ENV POSTGRES_JNDI_ENABLED=false ENV CONFIG_DIR=/opt/config ENV CONFIG_OVERRIDES_DIR=/opt/config_overrides +ENV HTTPS_ENABLED=false +ENV HTTPS_KEYSTORE_FILE=/opt/keystore.jks +ENV HTTPS_KEYSTORE_PASSWORD=changeit +ENV HTTPS_KEY_ALIAS=server + EXPOSE 8080 +EXPOSE 8443 WORKDIR /tmp diff --git a/README.md b/README.md index 243da2d..c1fba2d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ This Dockerfile can be used to create images for all geoserver versions since 2. * CORS support * Support extensions * Support additional libraries + * Support for PostgreSQL JNDI + * Support for HTTPS This README.md file covers use of official docker image, additional [build](BUILD.md) and [release](RELEASE.md) instructions are available. @@ -146,6 +148,16 @@ In geoserver, you can then reference this JNDI resource using the name `java:com For advanced customization of the connection pool, you can provide your own customized "context.xml" file to Apache Tomcat by mounting it to the container at ``/opt/config_overrides/context.xml``. +## How to enable HTTPS? + +To enable HTTPS, mount a JKS file to the container (ex. `/opt/keystore.jks`) and provide the following environment +variables: + +* ``HTTPS_ENABLED`` to `true` +* ``HTTPS_KEYSTORE_FILE`` (defaults to `/opt/keystore.jks`) +* ``HTTPS_KEYSTORE_PASSWORD`` (defaults to `changeit`) +* ``HTTPS_KEY_ALIAS`` (defaults to `server`) + ## How to use the docker-compose demo? The ``docker-compose-demo.yml`` to build with your own data directory and extensions. diff --git a/config/server-https.xml b/config/server-https.xml new file mode 100644 index 0000000..23c84cf --- /dev/null +++ b/config/server-https.xml @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/startup.sh b/startup.sh index 9195d26..d0964e1 100755 --- a/startup.sh +++ b/startup.sh @@ -111,5 +111,14 @@ if [ "${POSTGRES_JNDI_ENABLED}" = "true" ]; then fi fi +if [ "${HTTPS_ENABLED}" = "true" ]; then + if [ ! -f "${HTTPS_KEYSTORE_FILE}" ]; then + echo "ERROR: HTTPS was enabled but keystore file was not mounted to container [${HTTPS_KEYSTORE_FILE}]" + exit 1 + fi + echo "Installing [${CATALINA_HOME}/conf/server.xml] with HTTPS support using substituted environment variables" + envsubst < "${CONFIG_DIR}"/server-https.xml > "${CATALINA_HOME}/conf/server.xml" +fi + # start the tomcat exec $CATALINA_HOME/bin/catalina.sh run