Skip to content

Commit 5ff8193

Browse files
committed
Merge pull request #3075 from carmstrong/pr-2976
feat(router): add optional HTTPs redirect
2 parents 3d59fef + a0ba176 commit 5ff8193

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

docs/customizing_deis/router_settings.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ setting description
4545
/deis/router/controller/timeout/connect proxy_connect_timeout for deis-controller (default: 10m)
4646
/deis/router/controller/timeout/read proxy_read_timeout for deis-controller (default: 20m)
4747
/deis/router/controller/timeout/send proxy_send_timeout for deis-controller (default: 20m)
48+
/deis/router/enforceHTTPS redirect all HTTP traffic to HTTPS (default: false)
4849
/deis/router/firewall/enabled nginx naxsi firewall enabled (default: false)
4950
/deis/router/firewall/errorCode nginx default firewall error code (default: 400)
5051
/deis/router/gzip nginx gzip setting (default: on)

docs/managing_deis/ssl-endpoints.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,18 @@ certificate chain, append the intermediate certs to the bottom of the sslCert va
8787
To secure all endpoints on the platform domain, you must use a wildcard certificate.
8888

8989

90+
Redirecting traffic to HTTPS
91+
----------------------------
92+
93+
Once your cluster is serving traffic over HTTPS, you can optionally instruct the router component
94+
to forward all traffic on HTTP to HTTPS (application traffic and requests to the controller component).
95+
96+
This is achieved with ``deisctl``:
97+
98+
.. code-block:: console
99+
100+
$ deisctl config router set enforceHTTPS=true
101+
102+
90103
.. _`installing an SSL cert for load balancing`: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/ssl-server-cert.html
91104
.. _`Product FAQ`: http://www.rackspace.com/knowledge_center/product-faq/cloud-load-balancers

router/image/templates/nginx.conf

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

58+
{{ $enforceHTTPS := or .deis_router_enforceHTTPS "false" }}
59+
5860
## start deis-controller
5961
{{ if .deis_controller_host }}
6062
upstream deis-controller {
@@ -88,6 +90,12 @@ http {
8890
{{ if eq $useFirewall "true" }}location /RequestDenied {
8991
return {{ $firewallErrorCode }};
9092
}{{ end }}
93+
94+
{{ if eq $enforceHTTPS "true" }}
95+
if ($http_x_forwarded_proto != "https") {
96+
rewrite ^(.*)$ https://$host$1 permanent;
97+
}
98+
{{ end }}
9199
}
92100
## end deis-controller
93101

@@ -157,6 +165,12 @@ http {
157165

158166
proxy_next_upstream error timeout http_502 http_503 http_504;
159167

168+
{{ if eq $enforceHTTPS "true" }}
169+
if ($http_x_forwarded_proto != "https") {
170+
rewrite ^(.*)$ https://$host$1 permanent;
171+
}
172+
{{ end }}
173+
160174
add_header X-Deis-Upstream $upstream_addr;
161175

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

0 commit comments

Comments
 (0)