Set backend host header for frontend proxy
Some checks failed
CI/CD Pipeline / Quality Gate (push) Failing after 8m28s
CI/CD Pipeline / Build and Deploy Dev via Compose (push) Has been skipped

This commit is contained in:
2026-06-21 11:08:47 +02:00
parent 77441df0cb
commit f43f2055e3
5 changed files with 27 additions and 5 deletions

View File

@@ -2,11 +2,13 @@
set -eu
: "${BACKEND_UPSTREAM:?BACKEND_UPSTREAM is required (example: http://analytical-panel-backend:8000)}"
: "${BACKEND_HOST_HEADER:?BACKEND_HOST_HEADER is required (example: analytical-panel-backend)}"
BACKEND_UPSTREAM="${BACKEND_UPSTREAM%/}"
export BACKEND_UPSTREAM
export BACKEND_HOST_HEADER
envsubst '${BACKEND_UPSTREAM}' \
envsubst '${BACKEND_UPSTREAM} ${BACKEND_HOST_HEADER}' \
< /etc/nginx/templates/default.conf.template \
> /etc/nginx/conf.d/default.conf

View File

@@ -25,7 +25,7 @@ server {
location = /api {
proxy_pass ${BACKEND_UPSTREAM}/api;
proxy_set_header Host $host;
proxy_set_header Host ${BACKEND_HOST_HEADER};
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;
@@ -33,7 +33,7 @@ server {
location /api/ {
proxy_pass ${BACKEND_UPSTREAM}/api/;
proxy_set_header Host $host;
proxy_set_header Host ${BACKEND_HOST_HEADER};
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;
@@ -41,7 +41,7 @@ server {
location = /health {
proxy_pass ${BACKEND_UPSTREAM}/health/;
proxy_set_header Host $host;
proxy_set_header Host ${BACKEND_HOST_HEADER};
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;
@@ -49,7 +49,7 @@ server {
location /health/ {
proxy_pass ${BACKEND_UPSTREAM}/health/;
proxy_set_header Host $host;
proxy_set_header Host ${BACKEND_HOST_HEADER};
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;