1+ {{define " service-block" }}
2+ location /{{.Location }} {
3+ {{if eq .HealthStatus " healthy" " " }}
4+ {{ if .Rewrite }}
5+ rewrite ^/{{ .Rewrite.Pattern }}(/| $ )(. *) {{ .Rewrite.Rewrite }}/$2 break;
6+ {{end }}
7+ {{ if eq .ProxyBuffering " off" }}proxy_buffering off;{{ end }}
8+ proxy_pass {{.URL }};
9+ {{else }}
10+ error_page 503 /errors/starting.html ;
11+ return 503;
12+ {{end }}
13+ }
14+ {{end }}
15+
116server {
217 include /etc/nginx/include.d /ssl.conf ;
318 include /etc/nginx/include.d /errors.conf ;
@@ -6,29 +21,6 @@ server {
621 include /etc/nginx/include.d /robots.conf ;
722 include /etc/nginx/app.conf.d /* .conf;
823
9- {{if .Maintenance}}
10- {{range .Services}}
11- {{if eq .Location "ces-exporter" }}
12- # allow ces-exporter access in maintenance mode
13- location /{{.Location}} {
14- {{ if .Rewrite }}
15- rewrite ^/{{ .Rewrite.Pattern }}(/|$)(.*) {{ .Rewrite.Rewrite }}/$2 break;
16- {{end}}
17-
18- {{ if eq .ProxyBuffering "off" }}
19- proxy_buffering off;
20- {{ end }}
21-
22- proxy_pass {{.URL}};
23- }
24- {{end}}
25- {{end}}
26-
27- location / {
28- return 503;
29- }
30- {{else}}
31-
3224 # default proxy settings
3325 proxy_set_header Host $http_host;
3426 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -47,29 +39,31 @@ server {
4739
4840 proxy_read_timeout 1d;
4941
50-
5142 # disable gzip encoding for proxy applications
5243 proxy_set_header Accept-Encoding identity;
5344
45+ {{if .Maintenance}}
46+ {{range .Services}}
47+ {{if eq .Location "ces-exporter" }}
48+ # allow ces-exporter access in maintenance mode
49+ {{template "service-block" .}}
50+ {{end}}
51+ {{end}}
52+
53+ # show 503 for all other services in maintenance mode
54+ location / {
55+ return 503;
56+ }
57+ {{else}}
58+
5459 include /etc/nginx/include.d/info.conf;
5560 include /etc/nginx/include.d/subfilters.conf;
5661 include /etc/nginx/include.d/default-dogu.conf;
5762 include /etc/nginx/include.d/customhtml.conf;
5863
5964 # services
6065 {{range .Services}}
61- location /{{.Location}} {
62- {{if eq .HealthStatus "healthy" "" }}
63- {{ if .Rewrite }}
64- rewrite ^/{{ .Rewrite.Pattern }}(/|$)(.*) {{ .Rewrite.Rewrite }}/$2 break;
65- {{end}}
66- {{ if eq .ProxyBuffering "off" }}proxy_buffering off;{{ end }}
67- proxy_pass {{.URL}};
68- {{else}}
69- error_page 503 /errors/starting.html;
70- return 503;
71- {{end}}
72- }
66+ {{template "service-block" .}}
7367 {{end}}
7468 # end of services
7569
0 commit comments