From 688e956287ea56f738069d4e911498e85b18933c Mon Sep 17 00:00:00 2001 From: segaq44 Date: Fri, 12 Dec 2025 11:21:37 +0100 Subject: [PATCH] fix: redirect with real scheme from X-Forwarded-Proto --- common/etc/nginx/templates/default.conf.template | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/etc/nginx/templates/default.conf.template b/common/etc/nginx/templates/default.conf.template index 19c13cc9..2c048173 100644 --- a/common/etc/nginx/templates/default.conf.template +++ b/common/etc/nginx/templates/default.conf.template @@ -13,6 +13,13 @@ map $request_uri $uri_full_path { "~^(?P.*?)(\?.*)*$" $path; } +# Retrieves the initial scheme send by the User Agent. This uses +# X-Forwarded-Proto header added by possible proxy or load balancer. +map $http_x_forwarded_proto $real_scheme { + default $http_x_forwarded_proto; + "" $scheme; +} + # Remove/replace a portion of request URL (if configured) map $uri_full_path $uri_path { "~^$STRIP_LEADING_DIRECTORY_PATH(.*)" $PREFIX_LEADING_DIRECTORY_PATH$1; @@ -304,7 +311,7 @@ server { # 302 to request without slashes # Adding a ? to the end of the replacement param in `rewrite` prevents it from # appending the query string. - rewrite ^ $scheme://$http_host$uri/$is_args$query_string? redirect; + rewrite ^ $real_scheme://$http_host$uri/$is_args$query_string? redirect; } # Provide a hint to the client on 405 errors of the acceptable request methods