Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixes #42] Dynamicully set CORS ALLOW ORIGINS #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docker/nginx/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions docker/nginx/geonode.conf.envsubst
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down