diff --git a/Dockerfile b/Dockerfile index 212fee5..dc0d4bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,6 +31,7 @@ ENV STABLE_PLUGIN_URL=$STABLE_PLUGIN_URL ENV ADDITIONAL_LIBS_DIR=/opt/additional_libs/ ENV ADDITIONAL_FONTS_DIR=/opt/additional_fonts/ ENV SKIP_DEMO_DATA=false +ENV ROOT_WEBAPP_REDIRECT=false # see https://docs.geoserver.org/stable/en/user/production/container.html ENV CATALINA_OPTS="\$EXTRA_JAVA_OPTS \ @@ -52,7 +53,7 @@ RUN apt update && \ rm -rf /var/lib/apt/lists/* WORKDIR /opt/ -RUN wget -q https://dlcdn.apache.org/tomcat/tomcat-9/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz && \ +RUN wget -q https://archive.apache.org/dist/tomcat/tomcat-9/v${TOMCAT_VERSION}/bin/apache-tomcat-${TOMCAT_VERSION}.tar.gz && \ tar xf apache-tomcat-${TOMCAT_VERSION}.tar.gz && \ rm apache-tomcat-${TOMCAT_VERSION}.tar.gz && \ rm -rf /opt/apache-tomcat-${TOMCAT_VERSION}/webapps/ROOT && \ diff --git a/README.md b/README.md index 74c8bd7..c8b1ad5 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,11 @@ docker run -it -p 80:8080 \ docker.osgeo.org/geoserver:2.21.1 ``` +### How to issue a redirect from the root ("/") to GeoServer web interface ("/geoserver/web")? + +By default, the ROOT webapp is not available which makes requests to the root endpoint "/" return a 404 error. +The environment variable `ROOT_WEBAPP_REDIRECT` can be set to `true` to issue a permanent redirect to the web interface. + ### How to download and install additional extensions on startup? The ``startup.sh`` script allows some customization on startup: diff --git a/startup.sh b/startup.sh index b8a3ec8..548623d 100755 --- a/startup.sh +++ b/startup.sh @@ -6,6 +6,22 @@ if [ "${SKIP_DEMO_DATA}" = "true" ]; then unset GEOSERVER_REQUIRE_FILE fi +## Add a permanent redirect (HTTP 301) from the root webapp ("/") to geoserver web interface ("/geoserver/web") +if [ "${ROOT_WEBAPP_REDIRECT}" = "true" ]; then + if [ ! -d $CATALINA_HOME/webapps/ROOT ]; then + mkdir $CATALINA_HOME/webapps/ROOT + fi + + cat > $CATALINA_HOME/webapps/ROOT/index.jsp << EOF +<% + final String redirectURL = "/geoserver/web/"; + response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); + response.setHeader("Location", redirectURL); +%> +EOF +fi + + ## install release data directory if needed before starting tomcat if [ ! -z "$GEOSERVER_REQUIRE_FILE" ] && [ ! -f "$GEOSERVER_REQUIRE_FILE" ]; then echo "Initialize $GEOSERVER_DATA_DIR from data directory included in geoserver.war"