From b1ff2136368c1f1cf633291232394b6ffeaf03ac Mon Sep 17 00:00:00 2001 From: Antoine A <> Date: Thu, 30 Nov 2023 02:51:10 +0000 Subject: Reuse PROTO logic and fix bank nginx.conf --- netzbon/config_libeufin_bank.sh | 14 +++----------- netzbon/config_nginx.sh | 7 +------ netzbon/main.sh | 8 ++++++++ netzbon/nginx-conf/bank.taler-nginx.conf | 15 +++------------ 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/netzbon/config_libeufin_bank.sh b/netzbon/config_libeufin_bank.sh index 822b379..dfe6e6b 100755 --- a/netzbon/config_libeufin_bank.sh +++ b/netzbon/config_libeufin_bank.sh @@ -44,22 +44,14 @@ fi # TODO: add sanity-checks for presence of other required env-vars -if test "${ENABLE_TLS:-}" == "y"; then - PROTO="https" -else - PROTO="http" -fi - say "Configure the bank with ${CURRENCY}..." # TODO is 20000000 big enough for admin dbt limit -# TODO With port should be use ? -PORT=9090 echo -e "[libeufin-bank]\n" \ "CURRENCY=${CURRENCY}\n"\ "DEFAULT_EXCHANGE=${PROTO}://exchange.$DOMAIN_NAME\n"\ "DEFAULT_ADMIN_DEBT_LIMIT=${CURRENCY}:20000000\n"\ "SERVE=tcp\n"\ - "PORT=$PORT\n"\ + "PORT=$BANK_PORT\n"\ >> /etc/libeufin/libeufin-bank.conf say "Setting up libeufin-bank database" @@ -83,7 +75,7 @@ curl --max-time 25 \ --retry-connrefused \ --retry-delay 3 \ --retry 10 \ - "http://localhost:$PORT" &>/dev/null + "http://localhost:$BANK_PORT" &>/dev/null say "DONE" say "Create exchange account..." @@ -96,7 +88,7 @@ wget \ --header='Content-type: application/json' \ --body-data="${BODY}" \ -O "$LAST_RESPONSE" \ - "http://localhost:$PORT/accounts" + "http://localhost:$BANK_PORT/accounts" say "DONE" EXCHANGE_PAYTO="$(cat "$LAST_RESPONSE" | jq -r .internal_payto_uri)/receiver-name=Exchange" diff --git a/netzbon/config_nginx.sh b/netzbon/config_nginx.sh index 6e90268..7d21ac5 100755 --- a/netzbon/config_nginx.sh +++ b/netzbon/config_nginx.sh @@ -3,14 +3,9 @@ source functions.sh source config/user.conf -if test "${ENABLE_TLS:-}" == "y"; then - PROTO="https" -else - PROTO="http" -fi - export PROTO export DOMAIN_NAME +export BANK_PORT envsubst "/etc/nginx/sites-available/backend.${DOMAIN_NAME}" envsubst "/etc/nginx/sites-available/bank.${DOMAIN_NAME}" diff --git a/netzbon/main.sh b/netzbon/main.sh index 5b0fdfe..98356e1 100755 --- a/netzbon/main.sh +++ b/netzbon/main.sh @@ -91,6 +91,14 @@ if test -z "${BANK_EXCHANGE_PASSWORD:-}"; then echo "BANK_EXCHANGE_PASSWORD=\"${BANK_EXCHANGE_PASSWORD}\"" >>config/internal.conf fi +# TODO With port should be use ? ask user ? +echo "BANK_PORT=9090" >>config/user.conf +if test "${ENABLE_TLS:-}" == "y"; then + echo "PROTO=\"https\"">>config/internal.conf +else + echo "PROTO=\"http\"">>config/internal.conf +fi + ./config_libeufin_bank.sh ./config_libeufin_nexus.sh ./config_nginx.sh diff --git a/netzbon/nginx-conf/bank.taler-nginx.conf b/netzbon/nginx-conf/bank.taler-nginx.conf index dcdd265..9e2ce5b 100644 --- a/netzbon/nginx-conf/bank.taler-nginx.conf +++ b/netzbon/nginx-conf/bank.taler-nginx.conf @@ -7,21 +7,12 @@ server { access_log /var/log/nginx/libeufin-sandbox.log; error_log /var/log/nginx/libeufin-sandbox.err; - location /demobanks/default { - proxy_pass http://localhost:5016; + # TODO should we proxy SPA with nginx for perf and fallback to bank server on 404 ? + location / { + proxy_pass http://localhost:${BANK_PORT}; #Fixes withdrawal http request proxy_set_header X-Forwarded-Proto "${PROTO}"; proxy_set_header X-Forwarded-Host "bank.${DOMAIN_NAME}"; proxy_set_header X-Forwarded-Prefix /; } - - location / { - index index.html; - alias /usr/share/libeufin/demobank-ui/; - } - - location = /demobank-ui-settings.js { - alias /etc/libeufin/demobank-ui-settings.js; - } - } -- cgit v1.2.3