This commit is contained in:
31
scripts/patch.sh
Executable file
31
scripts/patch.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user