From c4947dac6dd4a8c5537514f6335e2dd072a56c55 Mon Sep 17 00:00:00 2001 From: David Cooper Date: Thu, 15 Aug 2024 19:57:55 -0400 Subject: [PATCH] Make proxy params a variable --- .../image/etc/nginx/templates/app.conf.j2 | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/server/nginx/image/etc/nginx/templates/app.conf.j2 b/server/nginx/image/etc/nginx/templates/app.conf.j2 index f5230f99..55bd2533 100644 --- a/server/nginx/image/etc/nginx/templates/app.conf.j2 +++ b/server/nginx/image/etc/nginx/templates/app.conf.j2 @@ -1,3 +1,10 @@ +{%- set PROXY_PARAMS %} + proxy_set_header Host $http_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; +{%- endset %} + map $http_upgrade $connection_upgrade { default upgrade; '' close; @@ -31,31 +38,22 @@ server { location /_internal/server_logs { internal; - proxy_set_header Host $http_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; proxy_buffering off; proxy_cache off; + {{ PROXY_PARAMS }} proxy_pass http://logs:8000/server_logs; } location = /api { proxy_http_version 1.1; proxy_set_header Connection $connection_upgrade; - proxy_set_header Host $http_host; proxy_set_header Upgrade $http_upgrade; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Real-IP $remote_addr; + {{ PROXY_PARAMS }} proxy_pass http://api:8000; } location / { - proxy_set_header Host $http_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; + {{ PROXY_PARAMS }} proxy_pass http://app:8000; } }