#!/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