From 5ee8a442b68e7d3c8307403410588310ddd59574 Mon Sep 17 00:00:00 2001 From: Felipe Bessa Coelho Date: Wed, 7 Aug 2024 15:40:34 +0100 Subject: [PATCH] add x-forwarded-* headers for messenger traffic --- ...erver_params => deskpro_server_params.tmpl} | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) rename etc/nginx/conf.d/{deskpro_server_params => deskpro_server_params.tmpl} (83%) diff --git a/etc/nginx/conf.d/deskpro_server_params b/etc/nginx/conf.d/deskpro_server_params.tmpl similarity index 83% rename from etc/nginx/conf.d/deskpro_server_params rename to etc/nginx/conf.d/deskpro_server_params.tmpl index 69c4425..2d5642b 100644 --- a/etc/nginx/conf.d/deskpro_server_params +++ b/etc/nginx/conf.d/deskpro_server_params.tmpl @@ -58,6 +58,24 @@ location ^~ /sys/services/messenger-api/ { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; + {{if getenv "HTTP_USER_REAL_PROTO_HEADER"}} + proxy_set_header X-Forwarded-Proto $http_{{ (getenv "HTTP_USER_REAL_PROTO_HEADER") | toLower | replaceAll "-" "_" }} if_not_empty; + {{else}} + proxy_set_header X-Forwarded-Proto $proto_for_scheme; + {{end}} + + {{if getenv "HTTP_USER_REAL_HOST_HEADER"}} + proxy_set_header X-Forwaded-Host $http_{{ (getenv "HTTP_USER_REAL_HOST_HEADER") | toLower | replaceAll "-" "_" }} if_not_empty; + {{else if getenv "HTTP_SERVE_HOST"}} + proxy_set_header X-Forwarded-Host "{{ getenv "HTTP_SERVE_HOST" "$http_host" }}"; + {{end}} + + {{if getenv "HTTP_USER_REAL_PORT_HEADER"}} + proxy_set_header X-Forwarded-Port $http_{{ (getenv "HTTP_USER_REAL_PORT_HEADER") | toLower | replaceAll "-" "_" }} if_not_empty; + {{else}} + proxy_set_header X-Forwarded-Port $port_for_scheme; + {{end}} + proxy_pass http://127.0.0.1:24000/; proxy_redirect / /sys/services/messenger-api/;