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

Commit 59e753c

Browse files
committed
feat(maintenance): Add support for maintenance mode for apps
1 parent c3b6ded commit 59e753c

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ _Note that Kubernetes annotation maps are all of Go type `map[string]string`. A
287287
| <a name="app-whitelist"></a>routable application | service | [router.deis.io/whitelist](#app-whitelist) | N/A | Comma-delimited list of addresses permitted to access the application (using IP or CIDR notation). These may either extend or override the router-wide default whitelist (if defined). Requests from all other addresses are denied. |
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`. |
290+
| <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`. |
290291

291292
#### Annotations by example
292293

model/model.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type RouterConfig struct {
5353
AppConfigs []*AppConfig
5454
BuilderConfig *BuilderConfig
5555
PlatformCertificate *Certificate
56-
Http2Enabled bool `key:"http2Enabled" constraint:"(?i)^(true|false)$"`
56+
Http2Enabled bool `key:"http2Enabled" constraint:"(?i)^(true|false)$"`
5757
}
5858

5959
func newRouterConfig() *RouterConfig {
@@ -112,6 +112,7 @@ 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)$"`
115116
}
116117

117118
func newAppConfig(routerConfig *RouterConfig) *AppConfig {

nginx/config.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ http {
188188
vhost_traffic_status_filter_by_set_key {{ $appConfig.Name }} application::*;
189189
190190
location / {
191-
{{ if $appConfig.Available }}proxy_buffering off;
191+
{{ if $appConfig.Maintenance }}return 503;{{ else if $appConfig.Available }}proxy_buffering off;
192192
proxy_set_header Host $host;
193193
proxy_set_header X-Forwarded-For $remote_addr;
194194
proxy_set_header X-Forwarded-Proto $access_scheme;
@@ -209,6 +209,12 @@ http {
209209
210210
proxy_pass http://{{$appConfig.ServiceIP}}:80;{{ else }}return 503;{{ end }}
211211
}
212+
{{ if $appConfig.Maintenance }}error_page 503 @maintenance;
213+
location @maintenance {
214+
root /;
215+
rewrite ^(.*)$ /www/maintenance.html break;
216+
}
217+
{{ end }}
212218
}
213219
214220
{{end}}{{end}}

rootfs/www/maintenance.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!DOCTYPE html>
2+
<title>Site Maintenance</title>

0 commit comments

Comments
 (0)