diff --git a/docker/.env b/docker/.env index 380e561..ae371de 100644 --- a/docker/.env +++ b/docker/.env @@ -12,7 +12,11 @@ # Image: ckan CKAN_SITE_ID=default +# Hostname, IP address and port of the catalog EPOS_MSL_HOST=epos-msl.ckan +EPOS_MSL_HOST_IP=127.0.0.1 +EPOS_MSL_HOST_PORT=18443 + # # On AWS, your CKAN_SITE_URL is the output of: # curl -s http://169.254.169.254/latest/meta-data/public-hostname diff --git a/docker/docker-compose-separate-msl-api.yml b/docker/docker-compose-separate-msl-api.yml index 8b3c9aa..21aa008 100644 --- a/docker/docker-compose-separate-msl-api.yml +++ b/docker/docker-compose-separate-msl-api.yml @@ -50,8 +50,9 @@ services: image: ghcr.io/utrechtuniversity/epos-msl-cat-nginx:latest environment: - EPOS_MSL_HOST=${EPOS_MSL_HOST} + - EPOS_MSL_HOST_PORT=${EPOS_MSL_HOST_PORT} ports: - - "18443:443" + - "${EPOS_MSL_HOST_IP}:${EPOS_MSL_HOST_PORT}:443" volumes: - nginx_config:/etc/nginx/conf.d - nginx_certificates:/etc/certificates @@ -80,6 +81,8 @@ services: - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} - MSLAPI_ROLE=WEBSERVER - FAST_API_TOKEN=${FAST_API_TOKEN} + - EPOS_MSL_HOST=${EPOS_MSL_HOST} + - EPOS_MSL_HOST_PORT=${EPOS_MSL_HOST_PORT} ports: - "80" volumes: @@ -94,6 +97,8 @@ services: - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} - MSLAPI_ROLE=QUEUE_WORKER - FAST_API_TOKEN=${FAST_API_TOKEN} + - EPOS_MSL_HOST=${EPOS_MSL_HOST} + - EPOS_MSL_HOST_PORT=${EPOS_MSL_HOST_PORT} volumes: - ckan_api_key:/ckan_api_key - mslapi_signal:/signal diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 933f6c4..4a63508 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -50,8 +50,9 @@ services: image: ghcr.io/utrechtuniversity/epos-msl-cat-nginx:latest environment: - EPOS_MSL_HOST=${EPOS_MSL_HOST} + - EPOS_MSL_HOST_PORT=${EPOS_MSL_HOST_PORT} ports: - - "18443:443" + - "${EPOS_MSL_HOST_IP}:${EPOS_MSL_HOST_PORT}:443" volumes: - nginx_config:/etc/nginx/conf.d - nginx_certificates:/etc/certificates @@ -83,6 +84,8 @@ services: environment: - FAST_API_TOKEN=${FAST_API_TOKEN} - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} + - EPOS_MSL_HOST=${EPOS_MSL_HOST} + - EPOS_MSL_HOST_PORT=${EPOS_MSL_HOST_PORT} - MSLAPI_ROLE=BOTH volumes: - ckan_api_key:/ckan_api_key diff --git a/docker/images/msl-api/msl-api-entrypoint.sh b/docker/images/msl-api/msl-api-entrypoint.sh index aed020d..5adc324 100644 --- a/docker/images/msl-api/msl-api-entrypoint.sh +++ b/docker/images/msl-api/msl-api-entrypoint.sh @@ -54,6 +54,14 @@ FLUSH PRIVILEGES; # Also configure the FAST-API key, which is passed via an environment variable perl -pi.bak -e '$fast_api_token=$ENV{FAST_API_TOKEN}; s/PUT_FASTAPI_TOKEN_HERE/"$fast_api_token"/ge' "/var/www/msl_api/.env" + # Configure App and and asset URL + if [ "$EPOS_MSL_HOST_PORT" -eq "443" ] + then export APP_ASSET_URL="https://${EPOS_MSL_HOST}" + else export APP_ASSET_URL="https://${EPOS_MSL_HOST}:${EPOS_MSL_HOST_PORT}" + fi + perl -pi.bak -e '$app_url=$ENV{APP_ASSET_URL}; s/PUT_APP_URL_HERE/"$app_url"/ge' "/var/www/msl_api/.env" + perl -pi.bak -e '$asset_url=$ENV{APP_ASSET_URL}; s/PUT_ASSET_URL_HERE/"$asset_url"/ge' "/var/www/msl_api/.env" + cd /var/www/msl_api # Initialize the MSL-API application set -x diff --git a/docker/images/msl-api/msl-api.env b/docker/images/msl-api/msl-api.env index 8b09175..e53bd19 100644 --- a/docker/images/msl-api/msl-api.env +++ b/docker/images/msl-api/msl-api.env @@ -2,8 +2,8 @@ APP_KEY= APP_NAME=MSL APP_ENV=production APP_DEBUG=false -APP_URL=https://epos-msl.ckan:18443 -ASSET_URL=https://epos-msl.ckan:18443 +APP_URL=PUT_APP_URL_HERE +ASSET_URL=PUT_ASSET_URL_HERE LOG_CHANNEL=stack LOG_LEVEL=debug diff --git a/docker/images/nginx/ckan.site b/docker/images/nginx/ckan.site index 6959627..240733e 100644 --- a/docker/images/nginx/ckan.site +++ b/docker/images/nginx/ckan.site @@ -43,7 +43,7 @@ server { location / { proxy_pass http://mslapi_webserver:80/; - proxy_set_header Host $host:18443; + proxy_set_header Host PUT_HOST_HEADER_HERE; proxy_set_header X-Forwarded-Proto https; proxy_cache cache; proxy_cache_bypass $cookie_auth_tkt; diff --git a/docker/images/nginx/nginx-entrypoint.sh b/docker/images/nginx/nginx-entrypoint.sh index 6799cdd..7c3f29a 100644 --- a/docker/images/nginx/nginx-entrypoint.sh +++ b/docker/images/nginx/nginx-entrypoint.sh @@ -20,5 +20,12 @@ else echo "Generating DHParam configuration..." echo "DHParam generation complete." fi +# Configure host header for reverse proxy +if [ "$EPOS_MSL_HOST_PORT" -eq "443" ] +then export HOST_HEADER="${EPOS_MSL_HOST}" +else export HOST_HEADER="${EPOS_MSL_HOST}:${EPOS_MSL_HOST_PORT}" +fi +perl -pi.bak -e '$host_header=$ENV{HOST_HEADER}; s/PUT_HOST_HEADER_HERE/"$host_header"/ge' "/etc/nginx/conf.d/ckan.conf" + ## Run Nginx nginx -g "daemon off;"