Allow redirection to GeoServer webapp from the ROOT webapp

pull/12/head
Cristhian Rivera 2022-10-16 13:11:59 +02:00
parent 26bfcae6bc
commit 422be0ae8d
No known key found for this signature in database
GPG Key ID: 29DC82012E0D1ED2
3 changed files with 22 additions and 0 deletions

View File

@ -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 \

View File

@ -59,6 +59,11 @@ using the same data directory.
This image populates GeoServer with demo data by default. For production scenarios this is typically not desired.
The environment variable `SKIP_DEMO_DATA` can be set to `true` to create an empty GeoServer.
### 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:

View File

@ -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"