Skip to content

Feature/add cors to root #56

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

Draft
wants to merge 2 commits into
base: feature/d8
Choose a base branch
from
Draft
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
16 changes: 3 additions & 13 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ export SITEMAP_URL=${SITEMAP_URL}
export NGINX_CORS_ENABLED=${NGINX_CORS_ENABLED:-0}
export NGINX_CORS_DOMAINS=${NGINX_CORS_DOMAINS}
if [ ${NGINX_CORS_ENABLED} == 1 ]; then
mkdir -p /etc/nginx/conf.d/fragments/location/php
mkdir -p /etc/nginx/conf.d/fragments/location/cors
if [ ! -z ${NGINX_CORS_DOMAINS} ]; then
print "Activating filtered CORS on domains: ${NGINX_CORS_DOMAINS}"
envsubst '${PHP_HOST} ${PHP_PORT} ${NGINX_DEFAULT_SERVER_PORT} ${NGINX_DEFAULT_SERVER_NAME} ${NGINX_DEFAULT_ROOT} ${DEFAULT_SERVER} ${NGINX_CORS_DOMAINS}' < /templates/fragments/location/php/cors-filtered.conf > /etc/nginx/conf.d/fragments/location/php/cors.conf
envsubst '${PHP_HOST} ${PHP_PORT} ${NGINX_DEFAULT_SERVER_PORT} ${NGINX_DEFAULT_SERVER_NAME} ${NGINX_DEFAULT_ROOT} ${DEFAULT_SERVER} ${NGINX_CORS_DOMAINS}' < /templates/fragments/location/cors/cors-filtered.conf > /etc/nginx/conf.d/fragments/location/cors/cors.conf
else
print "Activating unfiltered CORS"
envsubst '${PHP_HOST} ${PHP_PORT} ${NGINX_DEFAULT_SERVER_PORT} ${NGINX_DEFAULT_SERVER_NAME} ${NGINX_DEFAULT_ROOT} ${DEFAULT_SERVER}' < /templates/fragments/location/php/cors-unfiltered.conf > /etc/nginx/conf.d/fragments/location/php/cors.conf
envsubst '${PHP_HOST} ${PHP_PORT} ${NGINX_DEFAULT_SERVER_PORT} ${NGINX_DEFAULT_SERVER_NAME} ${NGINX_DEFAULT_ROOT} ${DEFAULT_SERVER}' < /templates/fragments/location/cors/cors-unfiltered.conf > /etc/nginx/conf.d/fragments/location/cors/cors.conf
fi
fi

Expand Down Expand Up @@ -99,15 +99,5 @@ for filename in /etc/nginx/conf.d/custom/*.conf; do
fi
done

# Rewrite root location fragments.
print "${0}: Rewriting root location fragments on /etc/nginx/conf.d/fragments/location/root/*.conf"
for filename in /etc/nginx/conf.d/fragments/location/root/*.conf; do
if [ -e "${filename}" ] ; then
cp ${filename} ${filename}.tmp
envsubst '${PHP_HOST} ${PHP_PORT} ${NGINX_DEFAULT_SERVER_PORT} ${NGINX_DEFAULT_SERVER_NAME} ${NGINX_DEFAULT_ROOT} ${NGINX_SUBFOLDER} ${NGINX_SUBFOLDER_ESCAPED} ${NGINX_OSB_BUCKET} ${NGINX_OSB_RESOLVER} ${DRUPAL_PUBLIC_FILES_PATH} ${NGINX_CACHE_CONTROL_HEADER}' < $filename.tmp > $filename
rm ${filename}.tmp
fi
done

envsubst '${NGINX_PHP_READ_TIMEOUT}' < /templates/fastcgi.conf > /etc/nginx/fastcgi.conf
exec nginx -g "daemon off;"
4 changes: 2 additions & 2 deletions templates/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ server {
}

location / {
include /etc/nginx/conf.d/fragments/location/root/*.conf;
include /etc/nginx/conf.d/fragments/location/cors/*.conf;
try_files $uri @rewrite;
}

Expand All @@ -98,7 +98,7 @@ server {

location ~ \.php$ {
include fastcgi.conf;
include /etc/nginx/conf.d/fragments/location/php/*.conf;
include /etc/nginx/conf.d/fragments/location/cors/*.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass php;
}
Expand Down
82 changes: 0 additions & 82 deletions templates/fragments/location/root/cors-filtered.conf

This file was deleted.

78 changes: 0 additions & 78 deletions templates/fragments/location/root/cors-unfiltered.conf

This file was deleted.