Skip to content

Commit b4cddba

Browse files
ianblenkecarmstrong
authored andcommitted
feat(router): add optional HTTPs redirect
1 parent 19d0371 commit b4cddba

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

router/image/templates/nginx.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ http {
127127

128128
## start service definitions for each application
129129
{{ $useSSL := or .deis_router_sslCert "false" }}
130+
{{ $enforceHttps := or .deis_router_enforceHttps "false" }}
130131
{{ $domains := .deis_domains }}{{ range $service := .deis_services }}{{ if $service.Nodes }}
131132
upstream {{ Base $service.Key }} {
132133
{{ range $upstream := $service.Nodes }}server {{ $upstream.Value }};
@@ -157,6 +158,12 @@ http {
157158

158159
proxy_next_upstream error timeout http_502 http_503 http_504;
159160

161+
{{ if ne $enforceHttps "false" }}
162+
if ($http_x_forwarded_proto != "https") {
163+
rewrite ^(.*)$ https://$host$1 permanent;
164+
}
165+
{{ end }}
166+
160167
add_header X-Deis-Upstream $upstream_addr;
161168

162169
proxy_pass http://{{ Base $service.Key }};

0 commit comments

Comments
 (0)