Files
marriage/.history/scripts/patch_20250808214025.sh
Andrey K. Choi cc87dcc0fa
Some checks failed
continuous-integration/drone/push Build is failing
api development
2025-08-08 21:58:36 +09:00

32 lines
1008 B
Bash

# scripts/patch_gateway_auth_header.sh
cat > scripts/patch_gateway_auth_header.sh <<'BASH'
#!/usr/bin/env bash
set -euo pipefail
CFG="infra/gateway/nginx.conf"
[ -f "$CFG" ] || { echo "Not found: $CFG"; exit 1; }
# Грубая, но надёжная вставка proxy_set_header Authorization во все блоки location к сервисам
awk '
/location[[:space:]]+\/(auth|profiles|match|chat|payments)\//,/\}/ {
print
if ($0 ~ /proxy_pass/ && !seen_auth) {
print " proxy_set_header Authorization $http_authorization;"
print " proxy_set_header X-Forwarded-Proto $scheme;"
print " proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;"
print " proxy_set_header Host $host;"
seen_auth=1
}
next
}
{ print }
/\}/ { seen_auth=0 }
' "$CFG" > "$CFG.tmp" && mv "$CFG.tmp" "$CFG"
echo "[gateway] restart..."
docker compose restart gateway
BASH
chmod +x scripts/patch_gateway_auth_header.sh
./scripts/patch_gateway_auth_header.sh