#!/usr/bin/env bash # Step 3 on the real shop gateway: its configuration still comes from the config server, only the routes are # swapped for one that points at the echo backend. $1 = built copy from upgrade.sh 3 or later. MOD=$(cd "$(dirname "$0")/.." && pwd); cd "$1" || exit 1 unset JAVA_TOOL_OPTIONS mkdir -p run/logs F=$MOD/output/25-shop-gateway-trusted-proxies.txt java "$MOD/scripts/Echo.java" 9091 > run/logs/echo.log 2>&1 & ECHO=$! java -Xmx200m -jar config-server/target/config-server-1.0.0.jar --eureka.client.enabled=true > run/logs/config-server.log 2>&1 & CS=$! trap 'kill $ECHO $CS 2>/dev/null' EXIT for _ in $(seq 1 90); do curl -fs localhost:8888/actuator/health >/dev/null 2>&1 && break; sleep 1; done { echo "# The shop gateway (WebMVC) on Spring Cloud 2026.0.0, client 127.0.0.1 sending: X-Forwarded-For: 198.51.100.7"; } > $F for value in '' '10\..*' '127\.0\.0\.1'; do TRUSTED_PROXIES="$value" java -Xmx200m -jar gateway/target/gateway-1.0.0.jar --eureka.client.enabled=false \ '--spring.cloud.gateway.server.webmvc.routes[0].id=headers' \ '--spring.cloud.gateway.server.webmvc.routes[0].uri=http://127.0.0.1:9091' \ '--spring.cloud.gateway.server.webmvc.routes[0].predicates[0]=Path=/headers' > run/logs/gateway.log 2>&1 & GW=$! for _ in $(seq 1 90); do curl -fs localhost:8080/actuator/health >/dev/null 2>&1 && break; sleep 1; done { echo; echo "=== TRUSTED_PROXIES=${value:-}" curl -s -H 'X-Forwarded-For: 198.51.100.7' localhost:8080/headers; } >> $F kill $GW; wait $GW 2>/dev/null done cat $F