Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added add_header to nginx::resource::location #402

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# [*location_deny*] - Array: Locations to deny connections from.
# [*www_root*] - Specifies the location on disk for files to be
# read from. Cannot be set in conjunction with $proxy
# [*add_header*] - Hash: Adds headers to the HTTP response when
# response code is equal to 200, 204, 301, 302 or 304.
# [*autoindex*] - Set it on 'on' to activate autoindex directory
# listing. Undef by default.
# [*index_files*] - Default index files for NGINX to read when
Expand Down Expand Up @@ -126,6 +128,7 @@
$location = $name,
$vhost = undef,
$www_root = undef,
$add_header = undef,
$autoindex = undef,
$index_files = [
'index.html',
Expand Down Expand Up @@ -185,6 +188,9 @@
if ($www_root != undef) {
validate_string($www_root)
}
if ($add_header != undef) {
validate_hash($add_header)
}
if ($autoindex != undef) {
validate_string($autoindex)
}
Expand Down
6 changes: 6 additions & 0 deletions spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
' deny 10.0.0.1;',
],
},
{
:title => 'should set add_header option',
:attr => 'add_header',
:value => {'CUSTOM_PARAM' => 'value'},
:match => /add_header\s+CUSTOM_PARAM\s+value;/,
},
{
:title => 'should contain ordered prepended directives',
:attr => 'location_cfg_prepend',
Expand Down
6 changes: 6 additions & 0 deletions spec/defines/resource_vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,12 @@
:value => 'spdy default',
:match => ' listen [::]:443 ssl spdy default;',
},
{
:title => 'should set add_header option',
:attr => 'add_header',
:value => {'CUSTOM_PARAM' => 'value'},
:match => /add_header\s+CUSTOM_PARAM\s+value;/,
},
{
:title => 'should set servername(s)',
:attr => 'server_name',
Expand Down
5 changes: 5 additions & 0 deletions templates/vhost/location_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
deny <%= deny_rule %>;
<%- end -%>
<% end -%>
<% if @add_header -%>
<%- @add_header.each do |key,value| -%>
add_header <%= key %> <%= value %>;
<%- end -%>
<% end -%>
<% if @location_custom_cfg_prepend -%>
<%- @location_custom_cfg_prepend.each do |key,value| -%>
<%- if value.is_a?(Hash) -%>
Expand Down