diff --git a/docker/nginx/docker-entrypoint.sh b/docker/nginx/docker-entrypoint.sh index e4b490a..b56770a 100644 --- a/docker/nginx/docker-entrypoint.sh +++ b/docker/nginx/docker-entrypoint.sh @@ -44,6 +44,14 @@ 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} +# Set Access-Control-Allow-Origin based on CORS_ALLOW_ALL_ORIGINS +if [ "$(echo ${CORS_ALLOW_ALL_ORIGINS} | tr '[:upper:]' '[:lower:]')" = "true" ]; then + export NGINX_ALLOW_ORIGIN="*" +else + NGINX_ALLOW_ORIGIN=$(echo "${SITEURL}" | sed -e 's|^https\?://||' -e 's|/$||') + export NGINX_ALLOW_ORIGIN +fi + defined_envs=$(printf '${%s} ' $(env | cut -d= -f1)) echo "Replacing environment variables" diff --git a/docker/nginx/geonode.conf.envsubst b/docker/nginx/geonode.conf.envsubst index 26b83dc..a5cbdf7 100644 --- a/docker/nginx/geonode.conf.envsubst +++ b/docker/nginx/geonode.conf.envsubst @@ -97,6 +97,7 @@ location / { add_header Content-Length 0; add_header Content-Type text/plain; add_header Access-Control-Max-Age 1728000; + add_header Access-Control-Allow-Origin "$NGINX_ALLOW_ORIGIN"; return 200; }