Set backend host header for frontend proxy
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user