diff --git a/Dockerfile b/Dockerfile index 0d1cd15..8f2cb11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -100,7 +100,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 e7d754a..e37f111 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. @@ -186,6 +188,16 @@ docker run -it -p 80:8080 \ docker.osgeo.org/geoserver:2.25.1 ``` +## 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 5be4084..23f9af9 100755 --- a/startup.sh +++ b/startup.sh @@ -144,6 +144,15 @@ if [ -d "${CONFIG_OVERRIDES_DIR}" ] && [ -f "${CONFIG_OVERRIDES_DIR}/web.xml" ]; envsubst < "${CONFIG_OVERRIDES_DIR}"/web.xml > "${CATALINA_HOME}/webapps/geoserver/WEB-INF/web.xml" 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 # CIS - Tomcat Benchmark recommendations: # * Turn off session facade recycling