feat: add an easy maintenance page support

This commit is contained in:
Bruno Léon 2015-03-17 17:06:54 +01:00
parent 3322fb5a0e
commit c18ba1d499
3 changed files with 17 additions and 0 deletions

View file

@ -231,6 +231,7 @@ define nginx::resource::vhost (
$owner = $::nginx::config::global_owner,
$group = $::nginx::config::global_group,
$mode = $::nginx::config::global_mode,
$maintenance = false,
) {
validate_re($ensure, '^(present|absent)$',

View file

@ -102,6 +102,14 @@ server {
add_header <%= key %> <%= @add_header[key] %>;
<%- end -%>
<% end -%>
<% if @maintenance -%>
set $maintenance "on";
<% else -%>
set $maintenance "off";
<% end -%>
if ($maintenance = "on") {
return 503;
}
<% if @rewrite_to_https -%>
if ($ssl_protocol = "") {
return 301 https://$host<% if @ssl_port.to_i != 443 %>:<%= @ssl_port %><% end %>$request_uri;

View file

@ -72,6 +72,14 @@ server {
<%- end -%>
<% end -%>
<% if @maintenance -%>
set $maintenance "on";
<% else -%>
set $maintenance "off";
<% end -%>
if ($maintenance = "on") {
return 503;
}
<% if Array(@resolver).count > 0 -%>
resolver <% Array(@resolver).each do |r| %> <%= r %><% end %>;
<% end -%>