fix
This commit is contained in:
+17
-4
@@ -13,10 +13,17 @@
|
||||
# совпадать со сборкой образа)
|
||||
set -e
|
||||
|
||||
: "${BACKEND_URL:=http://localhost:8080}"
|
||||
: "${BACKEND_URL:=http://app:8080}"
|
||||
: "${API_BASE_URL:=/api}"
|
||||
: "${BASE_PATH:=/admin/}"
|
||||
|
||||
# Схема и host:port из BACKEND_URL: nginx резолвит апстрим в РАНТАЙМЕ (через
|
||||
# переменную + docker DNS), иначе отсутствие хоста на старте роняет nginx
|
||||
# («host not found in upstream»), например при автономном запуске без стека back.
|
||||
BACKEND_SCHEME=$(printf '%s' "$BACKEND_URL" | sed -nE 's#^(https?)://.*#\1#p')
|
||||
BACKEND_HOST_PORT=$(printf '%s' "$BACKEND_URL" | sed -E 's#^[a-z]+://##; s#/$##')
|
||||
case "$BACKEND_SCHEME" in http|https) ;; *) BACKEND_SCHEME=http; BACKEND_HOST_PORT="$BACKEND_URL";; esac
|
||||
|
||||
echo "app-config: backend=$BACKEND_URL apiBase=$API_BASE_URL base=$BASE_PATH"
|
||||
|
||||
cat > /usr/share/nginx/html/config.js <<EOF
|
||||
@@ -34,6 +41,9 @@ server {
|
||||
server_name _;
|
||||
absolute_redirect off;
|
||||
|
||||
# Docker embedded DNS: резолвим апстрим-бэкенд в рантайме (см. \$gorodar_backend)
|
||||
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
@@ -57,7 +67,8 @@ server {
|
||||
# Бэкенд: API + собственная авторизация (/oauth2/*, /.well-known/*).
|
||||
# Same-origin — CORS не нужен. Лимит 25m — чуть выше multipart-лимита бэкенда (22MB).
|
||||
location /api/ {
|
||||
proxy_pass ${BACKEND_URL};
|
||||
set \$gorodar_backend "${BACKEND_SCHEME}://${BACKEND_HOST_PORT}";
|
||||
proxy_pass \$gorodar_backend;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
@@ -65,14 +76,16 @@ server {
|
||||
client_max_body_size 25m;
|
||||
}
|
||||
location /oauth2/ {
|
||||
proxy_pass ${BACKEND_URL};
|
||||
set \$gorodar_backend "${BACKEND_SCHEME}://${BACKEND_HOST_PORT}";
|
||||
proxy_pass \$gorodar_backend;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||
}
|
||||
location /.well-known/ {
|
||||
proxy_pass ${BACKEND_URL};
|
||||
set \$gorodar_backend "${BACKEND_SCHEME}://${BACKEND_HOST_PORT}";
|
||||
proxy_pass \$gorodar_backend;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in New Issue
Block a user