Skip to content

Commit

Permalink
Merge pull request #2222 from uwgsit/apache_vhost_proxy_pass_match_di…
Browse files Browse the repository at this point in the history
…rectories

apache::vhost ProxyPassMatch in Location containers
  • Loading branch information
david22swan authored May 24, 2022
2 parents 515041e + 65c169e commit bff20f9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,8 @@
# Values: `directory`, `files`, `proxy`, `location`, `directorymatch`, `filesmatch`,
# `proxymatch` or `locationmatch`. If you set `provider` to `directorymatch`, it
# uses the keyword `DirectoryMatch` in the Apache config file.<br />
# proxy_pass and proxy_pass_match are supported like their parameters to apache::vhost, and will
# be rendered without their path parameter as this will be inherited from the Location/LocationMatch container.
# An example use of `directories`:
# ``` puppet
# apache::vhost { 'files.example.net':
Expand Down
19 changes: 19 additions & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,20 @@
},
],
},
{
'path' => '^/proxy',
'provider' => 'locationmatch',
'proxy_pass_match' => [
{
'url' => 'http://backend-b/',
'keywords' => ['noquery', 'interpolate'],
'params' => {
'retry' => '0',
'timeout' => '5',
},
},
],
},
{
'path' => '/var/www/node-app/public',
'passenger_enabled' => true,
Expand Down Expand Up @@ -697,6 +711,11 @@
content: %r{^\s+ProxyPass http://backend-b/ retry=0 timeout=5 noquery interpolate$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+ProxyPassMatch http://backend-b/ retry=0 timeout=5 noquery interpolate$},
)
}
it {
is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
content: %r{^\s+Options\sIndexes\sFollowSymLinks\sMultiViews$},
Expand Down
14 changes: 11 additions & 3 deletions templates/vhost/_directories.erb
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,17 @@
<%- end -%>
<%- end -%>
<%- end -%>
<%- if directory['proxy_pass'] and directory['provider'] and directory['provider'].match('location') -%>
<%- directory['proxy_pass'].flatten.compact.each do |proxy| -%>
ProxyPass <%= proxy['url'] -%>
<%- if (directory['proxy_pass'] or directory['proxy_pass_match']) and directory['provider'] and directory['provider'].match('location') -%>
<%# In a Location container, only one of ProxyPass or ProxyPassMatch are allowed, so only need to handle on case at a time -%>
<%- if directory['proxy_pass_match']
proxy_pass = 'ProxyPassMatch'
directory_proxy_pass = directory['proxy_pass_match']
else
proxy_pass = 'ProxyPass'
directory_proxy_pass = directory['proxy_pass']
end -%>
<%- directory_proxy_pass.flatten.compact.each do |proxy| -%>
<%= proxy_pass -%> <%= proxy['url'] -%>
<%- if proxy['params'] -%>
<%- proxy['params'].keys.sort.each do |key| -%> <%= key %>=<%= proxy['params'][key] -%>
<%- end -%>
Expand Down

0 comments on commit bff20f9

Please sign in to comment.