diff --git a/k8s/nginx-https/container/nginx.conf.template b/k8s/nginx-https/container/nginx.conf.template index 455ac356..21f3257d 100644 --- a/k8s/nginx-https/container/nginx.conf.template +++ b/k8s/nginx-https/container/nginx.conf.template @@ -115,7 +115,7 @@ http { } # POST requests get forwarded to BDB. - if ($request_method = POST ) {} + if ($request_method = POST ) { proxy_pass http://$bdb_backend:BIGCHAINDB_API_PORT; } diff --git a/k8s/nginx-https/container/nginx_entrypoint.bash b/k8s/nginx-https/container/nginx_entrypoint.bash index f7431b37..8f3227df 100755 --- a/k8s/nginx-https/container/nginx_entrypoint.bash +++ b/k8s/nginx-https/container/nginx_entrypoint.bash @@ -5,6 +5,7 @@ set -euo pipefail threescale_auth_mode="threescale" secret_token_auth_mode="secret-token" + # Cluster vars cluster_fqdn=`printenv CLUSTER_FQDN` cluster_frontend_port=`printenv CLUSTER_FRONTEND_PORT` @@ -15,18 +16,14 @@ dns_server=`printenv DNS_SERVER` health_check_port=`printenv HEALTH_CHECK_PORT` authorization_mode=`printenv AUTHORIZATION_MODE` - # MongoDB vars -mongo_frontend_port=`printenv MONGODB_FRONTEND_PORT` mongo_backend_host=`printenv MONGODB_BACKEND_HOST` mongo_backend_port=`printenv MONGODB_BACKEND_PORT` - # OpenResty vars openresty_backend_host=`printenv OPENRESTY_BACKEND_HOST` openresty_backend_port=`printenv OPENRESTY_BACKEND_PORT` - # BigchainDB vars bdb_backend_host=`printenv BIGCHAINDB_BACKEND_HOST` bdb_api_port=`printenv BIGCHAINDB_API_PORT` @@ -37,9 +34,9 @@ tm_pub_key_access_port=`printenv TM_PUB_KEY_ACCESS_PORT` tm_backend_host=`printenv TM_BACKEND_HOST` tm_p2p_port=`printenv TM_P2P_PORT` + # sanity check if [[ -z "${cluster_frontend_port:?CLUSTER_FRONTEND_PORT not specified. Exiting!}" || \ - -z "${mongo_frontend_port:?MONGODB_FRONTEND_PORT not specified. Exiting!}" || \ -z "${mongo_backend_host:?MONGODB_BACKEND_HOST not specified. Exiting!}" || \ -z "${mongo_backend_port:?MONGODB_BACKEND_PORT not specified. Exiting!}" || \ -z "${openresty_backend_port:?OPENRESTY_BACKEND_PORT not specified. Exiting!}" || \ @@ -52,8 +49,7 @@ if [[ -z "${cluster_frontend_port:?CLUSTER_FRONTEND_PORT not specified. Exiting! -z "${cluster_fqdn:?CLUSTER_FQDN not specified. Exiting!}" || \ -z "${tm_pub_key_access_port:?TM_PUB_KEY_ACCESS_PORT not specified. Exiting!}" || \ -z "${tm_backend_host:?TM_BACKEND_HOST not specified. Exiting!}" || \ - -z "${tm_p2p_port:?TM_P2P_PORT not specified. Exiting!}" || \ - -z "${authorization_mode:-threescale_auth_mode}" ]]; then # Set the default authorization mode to threescale + -z "${tm_p2p_port:?TM_P2P_PORT not specified. Exiting!}" ]]; then echo "Missing required environment variables. Exiting!" exit 1 else @@ -61,7 +57,6 @@ else echo CLUSTER_FRONTEND_PORT="$cluster_frontend_port" echo DNS_SERVER="$dns_server" echo HEALTH_CHECK_PORT="$health_check_port" - echo MONGODB_FRONTEND_PORT="$mongo_frontend_port" echo MONGODB_BACKEND_HOST="$mongo_backend_host" echo MONGODB_BACKEND_PORT="$mongo_backend_port" echo OPENRESTY_BACKEND_HOST="$openresty_backend_host" @@ -77,7 +72,7 @@ fi if [[ ${authorization_mode} == ${secret_token_auth_mode} ]]; then NGINX_CONF_FILE=/etc/nginx/nginx.conf secret_access_token=`printenv SECRET_ACCESS_TOKEN` - sed -i "s|SECRET_ACCESS_TOKEN|${secret_token_header}|g" + sed -i "s|SECRET_ACCESS_TOKEN|${secret_access_token}|g" ${NGINX_CONF_FILE} elif [[ ${authorization_mode} == ${threescale_auth_mode} ]]; then NGINX_CONF_FILE=/etc/nginx/nginx-threescale.conf sed -i "s|OPENRESTY_BACKEND_PORT|${openresty_backend_port}|g" ${NGINX_CONF_FILE} @@ -90,7 +85,6 @@ fi # configure the nginx.conf file with env variables sed -i "s|CLUSTER_FQDN|${cluster_fqdn}|g" ${NGINX_CONF_FILE} sed -i "s|CLUSTER_FRONTEND_PORT|${cluster_frontend_port}|g" ${NGINX_CONF_FILE} -sed -i "s|MONGODB_FRONTEND_PORT|${mongo_frontend_port}|g" ${NGINX_CONF_FILE} sed -i "s|MONGODB_BACKEND_HOST|${mongo_backend_host}|g" ${NGINX_CONF_FILE} sed -i "s|MONGODB_BACKEND_PORT|${mongo_backend_port}|g" ${NGINX_CONF_FILE} sed -i "s|BIGCHAINDB_BACKEND_HOST|${bdb_backend_host}|g" ${NGINX_CONF_FILE}