Allow setting proxy base URL in environment
parent
d151510c1e
commit
6110863817
10
README.md
10
README.md
|
|
@ -74,9 +74,13 @@ The environment variable `ROOT_WEBAPP_REDIRECT` can be set to `true` to issue a
|
||||||
|
|
||||||
The ``startup.sh`` script allows some customization on startup:
|
The ``startup.sh`` script allows some customization on startup:
|
||||||
|
|
||||||
* ``INSTALL_EXTENSIONS`` to ``true`` to download and install extensions
|
* ``INSTALL_EXTENSIONS`` to ``true`` to download and install extensions.
|
||||||
* ``STABLE_EXTENSIONS`` list of extensions to download and install
|
* ``STABLE_EXTENSIONS`` list of extensions to download and install.
|
||||||
* ``CORS_ENABLED``
|
* ``CORS_ENABLED`` to ``true`` to enable CORS support. The following environment variables can be used to customize the CORS configuration.
|
||||||
|
* ``CORS_ALLOWED_ORIGINS`` (default ``*``)
|
||||||
|
* ``CORS_ALLOWED_METHODS`` (default ``GET,POST,PUT,DELETE,HEAD,OPTIONS``)
|
||||||
|
* ``CORS_ALLOWED_HEADERS`` (default ``*``)
|
||||||
|
* ``PROXY_BASE_URL`` to the base URL of the GeoServer web app if GeoServer is behind a proxy. Example: ``https://example.com/geoserver``.
|
||||||
|
|
||||||
Example installing wps and ysld extensions:
|
Example installing wps and ysld extensions:
|
||||||
|
|
||||||
|
|
|
||||||
20
startup.sh
20
startup.sh
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo "Welcome to GeoServer $GEOSERVER_VERSION"
|
echo "Welcome to GeoServer $GEOSERVER_VERSION"
|
||||||
|
|
||||||
|
GEOSERVER_WEB_XML="$CATALINA_HOME/webapps/geoserver/WEB-INF/web.xml"
|
||||||
|
|
||||||
## Skip demo data
|
## Skip demo data
|
||||||
if [ "${SKIP_DEMO_DATA}" = "true" ]; then
|
if [ "${SKIP_DEMO_DATA}" = "true" ]; then
|
||||||
unset GEOSERVER_REQUIRE_FILE
|
unset GEOSERVER_REQUIRE_FILE
|
||||||
|
|
@ -52,8 +54,8 @@ fi
|
||||||
# to the end of the web.xml
|
# to the end of the web.xml
|
||||||
# (this will only happen if our filter has not yet been added before)
|
# (this will only happen if our filter has not yet been added before)
|
||||||
if [ "${CORS_ENABLED}" = "true" ]; then
|
if [ "${CORS_ENABLED}" = "true" ]; then
|
||||||
if ! grep -q DockerGeoServerCorsFilter "$CATALINA_HOME/webapps/geoserver/WEB-INF/web.xml"; then
|
if ! grep -q DockerGeoServerCorsFilter "${GEOSERVER_WEB_XML}"; then
|
||||||
echo "Enable CORS for $CATALINA_HOME/webapps/geoserver/WEB-INF/web.xml"
|
echo "Enable CORS for ${GEOSERVER_WEB_XML}"
|
||||||
sed -i "\:</web-app>:i\\
|
sed -i "\:</web-app>:i\\
|
||||||
<filter>\n\
|
<filter>\n\
|
||||||
<filter-name>DockerGeoServerCorsFilter</filter-name>\n\
|
<filter-name>DockerGeoServerCorsFilter</filter-name>\n\
|
||||||
|
|
@ -74,7 +76,19 @@ if [ "${CORS_ENABLED}" = "true" ]; then
|
||||||
<filter-mapping>\n\
|
<filter-mapping>\n\
|
||||||
<filter-name>DockerGeoServerCorsFilter</filter-name>\n\
|
<filter-name>DockerGeoServerCorsFilter</filter-name>\n\
|
||||||
<url-pattern>/*</url-pattern>\n\
|
<url-pattern>/*</url-pattern>\n\
|
||||||
</filter-mapping>" "$CATALINA_HOME/webapps/geoserver/WEB-INF/web.xml";
|
</filter-mapping>" "${GEOSERVER_WEB_XML}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${PROXY_BASE_URL}" ]; then
|
||||||
|
if ! grep -q StartupProxyBaseUrl "${GEOSERVER_WEB_XML}"; then
|
||||||
|
echo "Set proxy URL for ${GEOSERVER_WEB_XML}"
|
||||||
|
sed -i "\:</web-app>:i\\
|
||||||
|
<!-- StartupProxyBaseUrl -->\n\
|
||||||
|
<context-param>\n\
|
||||||
|
<param-name>PROXY_BASE_URL</param-name>\n\
|
||||||
|
<param-value>${PROXY_BASE_URL}</param-value>\n\
|
||||||
|
</context-param>" "${GEOSERVER_WEB_XML}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue