Skip to content

Commit 821e166

Browse files
author
Alexander Wenzowski
committed
fix(router): enforce HTTPS correctly when not behind an elb
1 parent daa11fd commit 821e166

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

router/image/templates/nginx.conf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ http {
5555
'' close;
5656
}
5757

58+
# trust http_x_forwarded_proto headers correctly indicate ssl offloading
59+
map $http_x_forwarded_proto $access_scheme {
60+
default $http_x_forwarded_proto;
61+
'' $scheme;
62+
}
63+
5864
{{ $enforceHTTPS := or .deis_router_enforceHTTPS "false" }}
5965

6066
## start deis-controller
@@ -92,7 +98,7 @@ http {
9298
}{{ end }}
9399

94100
{{ if eq $enforceHTTPS "true" }}
95-
if ($http_x_forwarded_proto != "https") {
101+
if ($access_scheme != "https") {
96102
rewrite ^(.*)$ https://$host$1 permanent;
97103
}
98104
{{ end }}
@@ -166,7 +172,7 @@ http {
166172
proxy_next_upstream error timeout http_502 http_503 http_504;
167173

168174
{{ if eq $enforceHTTPS "true" }}
169-
if ($http_x_forwarded_proto != "https") {
175+
if ($access_scheme != "https") {
170176
rewrite ^(.*)$ https://$host$1 permanent;
171177
}
172178
{{ end }}

0 commit comments

Comments
 (0)