From a9f5c5a6a9085704059f18eacb770aaa5561ac42 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 19 Dec 2017 04:24:14 +0000 Subject: [PATCH] etc/nginx/inc/https-only.conf --- etc/nginx/inc/https-only.conf | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/etc/nginx/inc/https-only.conf b/etc/nginx/inc/https-only.conf index 9618519d..280ca455 100644 --- a/etc/nginx/inc/https-only.conf +++ b/etc/nginx/inc/https-only.conf @@ -1,5 +1,9 @@ -set $redirect 0; -if ( $scheme = http ) { set $redirect 1; } +set $_https_only 0; +if ( $scheme = http ) { set $_https_only 1; } # Live is behind a load balancer which do only http queries -if ($http_x_forwarded_proto = "https") { set $redirect 0; } -if ( $redirect = 1 ) { return 301 https://$host$request_uri; } +if ($http_x_forwarded_proto = "https") { set $_https_only 0; } + +if ( $https_only = "") { set $https_only ""; } +if ( $https_only != "") { set $_https_only $https_only; } + +if ( $_https_only = 1 ) { return 301 https://$host$request_uri; } -- 2.47.3