-
Notifications
You must be signed in to change notification settings - Fork 39
Description
Overview
There are cases where the Nginx deployed with GeoNode sits itself behind an HTTP proxy, and this proxy often performs the SSL termination itself.
In this cases Nginx is served over port 80 and the HTTP_HOST variable is used to set the server name, instead of HTTPS_HOST.
The scheme forwarded by Nginx is obtained from the HTTP(S)_HOST variable, so if Nginx is served over 80, it will forward the http scheme to Django, even if GeoNode is served over https by the external HTTP server. This breaks the GeoNode APIs, because they get advertized (URLS and links inside the API responses) as being served over http, instead of https.
We introduce a new optional HTTP_FORWARDED_SCHEME .env variable that can be set to force the scheme forwarded by Nginx.
In case it is empty the current heuristic based on the host is maintained.
Solution
- Add
HTTP_FORWARDED_SCHEMEto the .env.sample file in GeoNode and GeoNode Project. - Add the following to Nginx docker-entrypoint.sh:
---
+++
@@ -35,11 +35,16 @@
if [ -z "${HTTPS_HOST}" ]; then
HTTP_SCHEME="http"
else
HTTP_SCHEME="https"
fi
+if [ -n "${HTTP_FORWARDED_SCHEME}" ]; then
+ echo "Force fowarded scheme ${HTTP_FORWARDED_SCHEME}"
+ HTTP_SCHEME=${HTTP_FORWARDED_SCHEME}
+fi
export HTTP_SCHEME=${HTTP_SCHEME:-http}
export GEONODE_LB_HOST_IP=${GEONODE_LB_HOST_IP:-django}
export GEONODE_LB_PORT=${GEONODE_LB_PORT:-8000}
export GEOSERVER_LB_HOST_IP=${GEOSERVER_LB_HOST_IP:-geoserver}
export GEOSERVER_LB_PORT=${GEOSERVER_LB_PORT:-8080}