diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index 8117e05e4..6af847434 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -23,6 +23,8 @@ # [*ipv6_listen_options*] - Extra options for listen directive like 'default' # to catchall. Template will allways add ipv6only=on. While issue # jfryman/puppet-nginx#30 is discussed, default value is 'default'. +# [*add_header*] - Hash: Adds headers to the HTTP response when +# response code is equal to 200, 204, 301, 302 or 304. # [*index_files*] - Default index files for NGINX to read when # traversing a directory # [*autoindex*] - Set it on 'on' to activate autoindex directory @@ -104,6 +106,7 @@ $ipv6_listen_ip = '::', $ipv6_listen_port = '80', $ipv6_listen_options = 'default', + $add_header = undef, $ssl = false, $ssl_cert = undef, $ssl_key = undef, @@ -151,6 +154,9 @@ validate_array($proxy_set_header) validate_array($index_files) validate_array($server_name) + if ($add_header != undef) { + validate_hash($add_header) + } # Variables $vhost_dir = "${nginx::config::nx_conf_dir}/sites-available" diff --git a/templates/vhost/vhost_header.erb b/templates/vhost/vhost_header.erb index 231160d52..d552fef7b 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/vhost/vhost_header.erb @@ -26,6 +26,9 @@ server { <% @proxy_set_header.each do |header| -%> proxy_set_header <%= header %>; <% end -%> +<% if @add_header -%><% @add_header.each do |key,value| -%> + add_header <%= key %> <%= value %>; +<% end -%><% end -%> <% if @rewrite_to_https -%> if ($ssl_protocol = "") { return 301 https://$host$request_uri; diff --git a/templates/vhost/vhost_ssl_header.erb b/templates/vhost/vhost_ssl_header.erb index 949da5653..99f0e1da1 100644 --- a/templates/vhost/vhost_ssl_header.erb +++ b/templates/vhost/vhost_ssl_header.erb @@ -33,5 +33,8 @@ server { <% @proxy_set_header.each do |header| -%> proxy_set_header <%= header %>; <% end -%> +<% if @add_header -%><% @add_header.each do |key,value| -%> + add_header <%= key %> <%= value %>; +<% end -%><% end -%>