From a578dcea5001641793612b0d2683531bdf7909ec Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Tue, 15 Oct 2013 22:49:33 +0200 Subject: [PATCH 1/4] feature: add configurable proxy_method to vhost and location resources Signed-off-by: Dominik Richter --- manifests/resource/location.pp | 3 +++ manifests/resource/vhost.pp | 4 ++++ templates/vhost/vhost_location_proxy.erb | 3 +++ 3 files changed, 10 insertions(+) diff --git a/manifests/resource/location.pp b/manifests/resource/location.pp index 3fd96e3f3..0c1723070 100644 --- a/manifests/resource/location.pp +++ b/manifests/resource/location.pp @@ -47,6 +47,8 @@ # The same zone can be used in multiple places. # [*proxy_cache_valid*] - This directive sets the time for caching # different replies. +# [*proxy_method*] - If defined, overrides the HTTP method of the +# request to be passed to the backend. # [*auth_basic*] - This directive includes testing name and password # with HTTP Basic Authentication. # [*auth_basic_user_file*] - This directive sets the htpasswd filename for @@ -111,6 +113,7 @@ $try_files = undef, $proxy_cache = false, $proxy_cache_valid = false, + $proxy_method = undef, $auth_basic = undef, $auth_basic_user_file = undef, $priority = 500 diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index b1d7f956a..acae2f306 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -59,6 +59,8 @@ # The same zone can be used in multiple places. # [*proxy_cache_valid*] - This directive sets the time for caching # different replies. +# [*proxy_method*] - If defined, overrides the HTTP method of the +# request to be passed to the backend. # [*auth_basic*] - This directive includes testing name and # password with HTTP Basic Authentication. # [*auth_basic_user_file*] - This directive sets the htpasswd filename for @@ -112,6 +114,7 @@ $proxy_set_header = [], $proxy_cache = false, $proxy_cache_valid = false, + $proxy_method = undef, $fastcgi = undef, $fastcgi_params = '/etc/nginx/fastcgi_params', $fastcgi_script = undef, @@ -199,6 +202,7 @@ proxy_read_timeout => $proxy_read_timeout, proxy_cache => $proxy_cache, proxy_cache_valid => $proxy_cache_valid, + proxy_method => $proxy_method, fastcgi => $fastcgi, fastcgi_params => $fastcgi_params, fastcgi_script => $fastcgi_script, diff --git a/templates/vhost/vhost_location_proxy.erb b/templates/vhost/vhost_location_proxy.erb index 33fe51495..557a6b1e8 100644 --- a/templates/vhost/vhost_location_proxy.erb +++ b/templates/vhost/vhost_location_proxy.erb @@ -8,6 +8,9 @@ <% end -%> proxy_pass <%= @proxy %>; proxy_read_timeout <%= @proxy_read_timeout %>; +<% if not @proxy_method.nil? -%> + proxy_method <%= @proxy_method %>; +<% end -%> <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> <%= key %> <%= value %>; <% end -%><% end -%> From a83c513ac49a009f5fa6e96b13d583952da55387 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Wed, 16 Oct 2013 00:01:50 +0200 Subject: [PATCH 2/4] feature: add configurable proxy_set_body to vhost and location resources Signed-off-by: Dominik Richter --- manifests/resource/location.pp | 2 ++ manifests/resource/vhost.pp | 3 +++ templates/vhost/vhost_location_proxy.erb | 3 +++ 3 files changed, 8 insertions(+) diff --git a/manifests/resource/location.pp b/manifests/resource/location.pp index 0c1723070..e1d491e54 100644 --- a/manifests/resource/location.pp +++ b/manifests/resource/location.pp @@ -49,6 +49,7 @@ # different replies. # [*proxy_method*] - If defined, overrides the HTTP method of the # request to be passed to the backend. +# [*proxy_set_body*] - If defined, sets the body passed to the backend. # [*auth_basic*] - This directive includes testing name and password # with HTTP Basic Authentication. # [*auth_basic_user_file*] - This directive sets the htpasswd filename for @@ -114,6 +115,7 @@ $proxy_cache = false, $proxy_cache_valid = false, $proxy_method = undef, + $proxy_set_body = undef, $auth_basic = undef, $auth_basic_user_file = undef, $priority = 500 diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index acae2f306..d452223eb 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -61,6 +61,7 @@ # different replies. # [*proxy_method*] - If defined, overrides the HTTP method of the # request to be passed to the backend. +# [*proxy_set_body*] - If defined, sets the body passed to the backend. # [*auth_basic*] - This directive includes testing name and # password with HTTP Basic Authentication. # [*auth_basic_user_file*] - This directive sets the htpasswd filename for @@ -115,6 +116,7 @@ $proxy_cache = false, $proxy_cache_valid = false, $proxy_method = undef, + $proxy_set_body = undef, $fastcgi = undef, $fastcgi_params = '/etc/nginx/fastcgi_params', $fastcgi_script = undef, @@ -203,6 +205,7 @@ proxy_cache => $proxy_cache, proxy_cache_valid => $proxy_cache_valid, proxy_method => $proxy_method, + proxy_set_body => $proxy_set_body, fastcgi => $fastcgi, fastcgi_params => $fastcgi_params, fastcgi_script => $fastcgi_script, diff --git a/templates/vhost/vhost_location_proxy.erb b/templates/vhost/vhost_location_proxy.erb index 557a6b1e8..78067a9e2 100644 --- a/templates/vhost/vhost_location_proxy.erb +++ b/templates/vhost/vhost_location_proxy.erb @@ -11,6 +11,9 @@ <% if not @proxy_method.nil? -%> proxy_method <%= @proxy_method %>; <% end -%> +<% if not @proxy_set_body.nil? -%> + proxy_set_body <%= @proxy_set_body %>; +<% end -%> <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> <%= key %> <%= value %>; <% end -%><% end -%> From 709c25e82e9fd2f6631c0e71381c4d32e39df453 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Wed, 27 Nov 2013 19:56:04 +0100 Subject: [PATCH 3/4] simplified checks if variables are set in vhost_location_proxy template kudos to Matthew Haughton for this suggestion Signed-off-by: Dominik Richter --- templates/vhost/vhost_location_proxy.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/vhost/vhost_location_proxy.erb b/templates/vhost/vhost_location_proxy.erb index 78067a9e2..1b7eb4c67 100644 --- a/templates/vhost/vhost_location_proxy.erb +++ b/templates/vhost/vhost_location_proxy.erb @@ -8,10 +8,10 @@ <% end -%> proxy_pass <%= @proxy %>; proxy_read_timeout <%= @proxy_read_timeout %>; -<% if not @proxy_method.nil? -%> +<% if @proxy_method -%> proxy_method <%= @proxy_method %>; <% end -%> -<% if not @proxy_set_body.nil? -%> +<% if @proxy_set_body -%> proxy_set_body <%= @proxy_set_body %>; <% end -%> <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> From aa611dc9382e2c37c6d44a9903adbc01fffed3f0 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Thu, 28 Nov 2013 11:42:34 +0100 Subject: [PATCH 4/4] added specs for proxy_method and proxy_set_body Signed-off-by: Dominik Richter --- spec/defines/resource_location_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/defines/resource_location_spec.rb b/spec/defines/resource_location_spec.rb index 8d6e3470d..9e4268ac6 100644 --- a/spec/defines/resource_location_spec.rb +++ b/spec/defines/resource_location_spec.rb @@ -64,6 +64,30 @@ :value => false, :notmatch => /proxy_cache/ }, + { + :title => 'should set proxy_method', + :attr => 'proxy_method', + :value => 'value', + :match => ' proxy_method value;', + }, + { + :title => 'should not set proxy_method', + :attr => 'proxy_method', + :value => false, + :notmatch => /proxy_method/, + }, + { + :title => 'should set proxy_set_body', + :attr => 'proxy_set_body', + :value => 'value', + :match => ' proxy_set_body value;', + }, + { + :title => 'should not set proxy_set_body', + :attr => 'proxy_set_body', + :value => false, + :notmatch => /proxy_set_body/, + }, { :title => 'should set proxy_pass', :attr => 'proxy',