Skip to content

Commit

Permalink
Merge pull request #1180 from roidelapluie/ProxyPassReverseCookiePath
Browse files Browse the repository at this point in the history
Support the mod_proxy ProxyPassReverseCookiePath directive
  • Loading branch information
DavidS committed Sep 1, 2015
2 parents 4a2b0db + 7cf4b96 commit 00b0da7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2113,11 +2113,14 @@ apache::vhost { 'site.name.fdqn':
'keywords' => ['nocanon', 'interpolate'] },
{ 'path' => '/f', 'url' => 'http://backend-f/',
'setenv' => ['proxy-nokeepalive 1','force-proxy-request-1.0 1']},
{ 'path' => '/g', 'url' => 'http://backend-g/',
'reverse_cookies' => [{'path' => '/g', 'url' => 'http://backend-g/',}], },
],
}
~~~

`reverse_urls` is optional and can be an array or a string. It is useful when used with `mod_proxy_balancer`.
`reverse_cookies` is optional and is used to set ProxyPassReverseCookiePath.
`params` is an optional parameter. It allows to provide the ProxyPass key=value parameters (Connection settings).
`setenv` is optional and is an array to set environment variables for the proxy directive, for details see http://httpd.apache.org/docs/current/mod/mod_proxy.html#envsettings

Expand Down
14 changes: 10 additions & 4 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,14 @@
'proxy_dest' => '/',
'proxy_pass' => [
{
'path' => '/a',
'url' => 'http://backend-a/',
'keywords' => ['noquery', 'interpolate'],
'params' => {
'path' => '/a',
'url' => 'http://backend-a/',
'keywords' => ['noquery', 'interpolate'],
'reverse_cookies' => [{
'path' => '/a',
'url' => 'http://backend-a/',
}],
'params' => {
'retry' => '0',
'timeout' => '5'
},
Expand Down Expand Up @@ -403,6 +407,8 @@
/SetEnv proxy-nokeepalive 1/) }
it { is_expected.to contain_concat__fragment('rspec.example.com-proxy').with_content(
/noquery interpolate/) }
it { is_expected.to contain_concat__fragment('rspec.example.com-proxy').with_content(
/ProxyPassReverseCookiePath\s+\/a\s+http:\/\//) }
it { is_expected.to contain_concat__fragment('rspec.example.com-rack') }
it { is_expected.to contain_concat__fragment('rspec.example.com-redirect') }
it { is_expected.to contain_concat__fragment('rspec.example.com-rewrite') }
Expand Down
5 changes: 5 additions & 0 deletions templates/vhost/_proxy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<%- if proxy['keywords'] %> <%= proxy['keywords'].join(' ') -%>
<%- end %>
<Location <%= proxy['path']%>>
<%- if not proxy['reverse_cookies'].nil? -%>
<%- Array(proxy['reverse_cookies']).each do |reverse_cookies| -%>
ProxyPassReverseCookiePath <%= reverse_cookies['path'] %> <%= reverse_cookies['url'] %>
<%- end -%>
<%- end -%>
<%- if proxy['reverse_urls'].nil? -%>
ProxyPassReverse <%= proxy['url'] %>
<%- else -%>
Expand Down

0 comments on commit 00b0da7

Please sign in to comment.