Skip to content
This repository was archived by the owner on May 27, 2019. It is now read-only.

Commit bd25b82

Browse files
author
Matthew Fisher
committed
feat(router): add app SSL config
1 parent 72251f4 commit bd25b82

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ _Note that Kubernetes annotation maps are all of Go type `map[string]string`. A
288288
| <a name="app-connect-timeout"></a>routable application | service | [router.deis.io/connectTimeout](#app-connect-timeout) | `"30s"` | nginx `proxy_connect_timeout` setting expressed in units `ms`, `s`, `m`, `h`, `d`, `w`, `M`, or `y`. |
289289
| <a name="app-tcp-timeout"></a>routable application | service | [router.deis.io/tcpTimeout](#app-tcp-timeout) | router's `defaultTimeout` | nginx `proxy_send_timeout` and `proxy_read_timeout` settings expressed in units `ms`, `s`, `m`, `h`, `d`, `w`, `M`, or `y`. |
290290
| <a name="app-maintenance"></a>routable application | service | [router.deis.io/maintenance](#app-maintenance) | `"false"` | Whether the app is under maintenance so that all traffic for this app is redirected to a static maintenance page with an error code of `503`. |
291+
| <a name="ssl-enforce"></a>routable application | service | [router.deis.io/ssl.enforce](#ssl-enforce) | `"false"` | Whether to respond with a 301 for all HTTP requests with a permanent redirect to the HTTPS equivalent address. |
291292

292293
#### Annotations by example
293294

model/model.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,16 @@ type AppConfig struct {
112112
CertMappings map[string]string `key:"certificates" constraint:"(?i)^((([a-z0-9]+(-*[a-z0-9]+)*)|((\\*\\.)?[a-z0-9]+(-*[a-z0-9]+)*\\.)+[a-z0-9]+(-*[a-z0-9]+)+):([a-z0-9]+(-*[a-z0-9]+)*)(\\s*,\\s*)?)+$"`
113113
Certificates map[string]*Certificate
114114
Available bool
115-
Maintenance bool `key:"maintenance" constraint:"(?i)^(true|false)$"`
115+
Maintenance bool `key:"maintenance" constraint:"(?i)^(true|false)$"`
116+
SSLConfig *SSLConfig `key:"ssl"`
116117
}
117118

118119
func newAppConfig(routerConfig *RouterConfig) *AppConfig {
119120
return &AppConfig{
120121
ConnectTimeout: "30s",
121122
TCPTimeout: routerConfig.DefaultTimeout,
122123
Certificates: make(map[string]*Certificate, 0),
124+
SSLConfig: newSSLConfig(),
123125
}
124126
}
125127

@@ -165,8 +167,8 @@ type SSLConfig struct {
165167

166168
func newSSLConfig() *SSLConfig {
167169
return &SSLConfig{
168-
Enforce: false,
169-
Protocols: "TLSv1 TLSv1.1 TLSv1.2",
170+
Enforce: false,
171+
Protocols: "TLSv1 TLSv1.1 TLSv1.2",
170172
// Default cipher suite:
171173
// - Prefer 128-Bit over 256-Bit encryptions (lower overhead)
172174
// - Prefer GCM over EDH over RSA auth (for Forward Secrecy)

nginx/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ http {
201201
proxy_set_header Upgrade $http_upgrade;
202202
proxy_set_header Connection $connection_upgrade;
203203
204-
{{ if $enforceHTTPS }}if ($access_scheme != "https") {
204+
{{ if or $enforceHTTPS $appConfig.SSLConfig.Enforce }}if ($access_scheme != "https") {
205205
return 301 https://$host$request_uri;
206206
}{{ end }}
207207

0 commit comments

Comments
 (0)