Skip to content

Commit

Permalink
Merge pull request voxpupuli#922 from gallagherrchris/master
Browse files Browse the repository at this point in the history
Support for proxy_pass_header directive.
  • Loading branch information
wyardley authored Oct 12, 2016
2 parents 6380151 + 25fea73 commit c40eb67
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
'Proxy ""',
],
$proxy_hide_header = [],
$proxy_pass_header = [],
$sendfile = 'on',
$server_tokens = 'on',
$spdy = 'off',
Expand Down Expand Up @@ -133,6 +134,7 @@
validate_string($multi_accept)
validate_array($proxy_set_header)
validate_array($proxy_hide_header)
validate_array($proxy_pass_header)
if ($proxy_http_version != undef) {
validate_string($proxy_http_version)
}
Expand Down
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
$proxy_send_timeout = undef,
$proxy_set_header = undef,
$proxy_hide_header = undef,
$proxy_pass_header = undef,
$sendfile = undef,
$server_tokens = undef,
$spdy = undef,
Expand Down Expand Up @@ -193,6 +194,7 @@
$proxy_send_timeout or
$proxy_set_header or
$proxy_hide_header or
$proxy_pass_header or
$proxy_temp_path or
$run_dir or
$sendfile or
Expand Down Expand Up @@ -278,6 +280,7 @@
proxy_send_timeout => $proxy_send_timeout,
proxy_set_header => $proxy_set_header,
proxy_hide_header => $proxy_hide_header,
proxy_pass_header => $proxy_pass_header,
proxy_temp_path => $proxy_temp_path,
run_dir => $run_dir,
sendfile => $sendfile,
Expand Down
3 changes: 3 additions & 0 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
# value of 90 seconds
# [*proxy_set_header*] - Array of vhost headers to set
# [*proxy_hide_header*] - Array of vhost headers to hide
# [*proxy_pass_header*] - Array of vhost headers to pass
# [*fastcgi*] - location of fastcgi (host:port)
# [*fastcgi_param*] - Set additional custom fastcgi_params
# [*fastcgi_params*] - optional alternative fastcgi_params file to use
Expand Down Expand Up @@ -153,6 +154,7 @@
$proxy_connect_timeout = $::nginx::config::proxy_connect_timeout,
$proxy_set_header = $::nginx::config::proxy_set_header,
$proxy_hide_header = $::nginx::config::proxy_hide_header,
$proxy_pass_header = $::nginx::config::proxy_pass_header,
$fastcgi = undef,
$fastcgi_param = undef,
$fastcgi_params = "${::nginx::config::conf_dir}/fastcgi_params",
Expand Down Expand Up @@ -226,6 +228,7 @@
validate_string($proxy_connect_timeout)
validate_array($proxy_set_header)
validate_array($proxy_hide_header)
validate_array($proxy_pass_header)
if ($fastcgi != undef) {
validate_string($fastcgi)
}
Expand Down
3 changes: 3 additions & 0 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
$proxy_connect_timeout = $::nginx::config::proxy_connect_timeout,
$proxy_set_header = $::nginx::config::proxy_set_header,
$proxy_hide_header = $::nginx::config::proxy_hide_header,
$proxy_pass_header = $::nginx::config::proxy_pass_header,
$proxy_cache = false,
$proxy_cache_key = undef,
$proxy_cache_use_stale = undef,
Expand Down Expand Up @@ -399,6 +400,7 @@
}
validate_array($proxy_set_header)
validate_array($proxy_hide_header)
validate_array($proxy_pass_header)
if ($proxy_cache != false) {
validate_string($proxy_cache)
}
Expand Down Expand Up @@ -625,6 +627,7 @@
proxy_http_version => $proxy_http_version,
proxy_set_header => $proxy_set_header,
proxy_hide_header => $proxy_hide_header,
proxy_pass_header => $proxy_pass_header,
proxy_set_body => $proxy_set_body,
proxy_buffering => $proxy_buffering,
fastcgi => $fastcgi,
Expand Down
9 changes: 9 additions & 0 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,15 @@
' proxy_hide_header header2;'
]
},
{
title: 'should contain ordered appended proxy_pass_header directives',
attr: 'proxy_pass_header',
value: %w(header1 header2),
match: [
' proxy_pass_header header1;',
' proxy_pass_header header2;'
]
},
{
title: 'should set client_body_temp_path',
attr: 'client_body_temp_path',
Expand Down
9 changes: 9 additions & 0 deletions spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,15 @@
%r{^\s+proxy_hide_header\s+X-TestHeader2 value2;}
]
},
{
title: 'should pass proxy headers',
attr: 'proxy_pass_header',
value: ['X-TestHeader1 value1', 'X-TestHeader2 value2'],
match: [
%r{^\s+proxy_pass_header\s+X-TestHeader1 value1;},
%r{^\s+proxy_pass_header\s+X-TestHeader2 value2;}
]
},
{
title: 'should set proxy_http_version',
attr: 'proxy_http_version',
Expand Down
3 changes: 3 additions & 0 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ http {
<% @proxy_hide_header.each do |header| -%>
proxy_hide_header <%= header %>;
<% end -%>
<% @proxy_pass_header.each do |header| -%>
proxy_pass_header <%= header %>;
<% end -%>
<% if @proxy_headers_hash_bucket_size -%>
proxy_headers_hash_bucket_size <%= @proxy_headers_hash_bucket_size %>;
<% end -%>
Expand Down
5 changes: 5 additions & 0 deletions templates/vhost/locations/proxy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
proxy_hide_header <%= header %>;
<%- end -%>
<% end -%>
<% unless @proxy_pass_header.nil? -%>
<%- @proxy_pass_header.each do |header| -%>
proxy_pass_header <%= header %>;
<%- end -%>
<% end -%>
<% if @proxy_cache -%>
proxy_cache <%= @proxy_cache %>;
<% end -%>
Expand Down

0 comments on commit c40eb67

Please sign in to comment.