From 7cf4b96f7806c9960ffd002b6c9f4a6cc8720800 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Wed, 12 Aug 2015 14:44:45 +0200 Subject: [PATCH] Support the mod_proxy ProxyPassReverseCookiePath directive --- README.md | 3 +++ spec/defines/vhost_spec.rb | 14 ++++++++++---- templates/vhost/_proxy.erb | 5 +++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9cfde923ed..58e8e03ebf 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index 5dce3f748b..3b9a6fdbd9 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -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' }, @@ -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') } diff --git a/templates/vhost/_proxy.erb b/templates/vhost/_proxy.erb index 71512fdba2..3f94af9112 100644 --- a/templates/vhost/_proxy.erb +++ b/templates/vhost/_proxy.erb @@ -18,6 +18,11 @@ <%- if proxy['keywords'] %> <%= proxy['keywords'].join(' ') -%> <%- end %> > + <%- 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 -%>