Skip to content

Commit

Permalink
Support ProxPassReverseCookieDomain directive (mod_proxy)
Browse files Browse the repository at this point in the history
  • Loading branch information
Onur Cem Celebi committed Dec 23, 2015
1 parent 791c20f commit f001dfb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -2260,13 +2260,13 @@ apache::vhost { 'site.name.fdqn':
{ '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_cookies' => [{'path' => '/g', 'url' => 'http://backend-g/',}, {'domain' => 'http://backend-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.
`reverse_cookies` is optional and is used to set ProxyPassReverseCookiePath and/or ProxyPassReverseCookieDomain.
`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
16 changes: 12 additions & 4 deletions spec/defines/vhost_spec.rb
Expand Up @@ -219,10 +219,16 @@
'path' => '/a',
'url' => 'http://backend-a/',
'keywords' => ['noquery', 'interpolate'],
'reverse_cookies' => [{
'path' => '/a',
'url' => 'http://backend-a/',
}],
'reverse_cookies' => [
{
'path' => '/a',
'url' => 'http://backend-a/',
},
{
'domain' => 'foo',
'url' => 'http://foo',
}
],
'params' => {
'retry' => '0',
'timeout' => '5'
Expand Down Expand Up @@ -425,6 +431,8 @@
/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-proxy').with_content(
/ProxyPassReverseCookieDomain\s+foo\s+http:\/\/foo/) }
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
7 changes: 6 additions & 1 deletion templates/vhost/_proxy.erb
Expand Up @@ -20,7 +20,12 @@
<Location <%= proxy['path']%>>
<%- if not proxy['reverse_cookies'].nil? -%>
<%- Array(proxy['reverse_cookies']).each do |reverse_cookies| -%>
ProxyPassReverseCookiePath <%= reverse_cookies['path'] %> <%= reverse_cookies['url'] %>
<%- if reverse_cookies['path'] -%>
ProxyPassReverseCookiePath <%= reverse_cookies['path'] %> <%= reverse_cookies['url'] %>
<%- end -%>
<%- if reverse_cookies['domain'] -%>
ProxyPassReverseCookieDomain <%= reverse_cookies['domain'] %> <%= reverse_cookies['url'] %>
<%- end -%>
<%- end -%>
<%- end -%>
<%- if proxy['reverse_urls'].nil? -%>
Expand Down

0 comments on commit f001dfb

Please sign in to comment.