Skip to content

Commit

Permalink
feat: add an easy maintenance page support
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoleon committed Mar 17, 2015
1 parent 3322fb5 commit c18ba1d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
$owner = $::nginx::config::global_owner,
$group = $::nginx::config::global_group,
$mode = $::nginx::config::global_mode,
$maintenance = false,
) {

validate_re($ensure, '^(present|absent)$',
Expand Down
8 changes: 8 additions & 0 deletions templates/vhost/vhost_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions templates/vhost/vhost_ssl_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>
Expand Down

0 comments on commit c18ba1d

Please sign in to comment.