Skip to content

Commit

Permalink
Merge pull request #208 from hdanes/add_header
Browse files Browse the repository at this point in the history
Add the possibility to add a header to the HTTP response
  • Loading branch information
James Fryman committed Dec 24, 2013
2 parents 69b77d7 + e0b8cb5 commit 7d1540b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions templates/vhost/vhost_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions templates/vhost/vhost_ssl_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,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 -%>


0 comments on commit 7d1540b

Please sign in to comment.