Skip to content

Commit

Permalink
Merge pull request #106 from bird-house/fix-geoserver-not-configured-…
Browse files Browse the repository at this point in the history
…properly-behind-proxy

Fix geoserver not configured properly behind proxy.

Hitting https://pavics.ouranos.ca/geoserver/wfs?request=GetCapabilities&version=1.1.0

Before fix (wrong scheme and wrong port):
```
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="http://pavics.ouranos.ca:80/geoserver/wfs"/>
<ows:Post xlink:href="http://pavics.ouranos.ca:80/geoserver/wfs"/>
</ows:HTTP>
</ows:DCP>
```

After fix:
```
<ows:Operation name="GetCapabilities">
<ows:DCP>
<ows:HTTP>
<ows:Get xlink:href="https://pavics.ouranos.ca:443/geoserver/wfs"/>
<ows:Post xlink:href="https://pavics.ouranos.ca:443/geoserver/wfs"/>
</ows:HTTP>
</ows:DCP>
```

This config automate manual step to set proxy base url in Geoserver UI https://docs.geoserver.org/2.9.3/user/configuration/globalsettings.html#proxy-base-url

I had to override the docker image entrypoint to edit the `server.xml` on the fly before starting Geoserver (Tomcat) since setting Java proxy config did not seem to work (see first commit).

Related to Ouranosinc/raven#297.
  • Loading branch information
tlvu authored Nov 25, 2020
2 parents cc4ca20 + 979e6e0 commit 0b473c7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions birdhouse/config/geoserver/entrypointwrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh -x

CONF_FILE="/usr/local/tomcat/conf/server.xml"

# Configure proxy support as per
# https://tomcat.apache.org/tomcat-8.0-doc/config/http.html#Proxy_Support
# This config automate manual step to set proxy base url in Geoserver UI:
# https://docs.geoserver.org/2.9.3/user/configuration/globalsettings.html#proxy-base-url
if ! grep " scheme=\"https\" proxyName=\"${PAVICS_FQDN_PUBLIC}\" proxyPort=\"443\" " $CONF_FILE; then
ORIGINAL_FILE="${CONF_FILE}.bak.proxy.$$"
cp -v $CONF_FILE $ORIGINAL_FILE
sed -i "s/<Connector /<Connector scheme=\"https\" proxyName=\"${PAVICS_FQDN_PUBLIC}\" proxyPort=\"443\" /g" $CONF_FILE
diff -u $ORIGINAL_FILE $CONF_FILE
fi

# chain existing entrypoint
catalina.sh run
5 changes: 5 additions & 0 deletions birdhouse/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,16 @@ services:
container_name: geoserver
ports:
- "8087:8080"
environment:
# for custom entrypoint
PAVICS_FQDN_PUBLIC: $PAVICS_FQDN_PUBLIC
volumes:
- /data/geoserver:/opt/geoserver/data_dir
- ./config/geoserver/web.xml:/usr/local/tomcat/conf/web.xml
- ./config/geoserver/entrypointwrapper:/entrypointwrapper:ro
links:
- postgis
entrypoint: /entrypointwrapper
restart: always

malleefowl:
Expand Down

0 comments on commit 0b473c7

Please sign in to comment.