Renamed params to fastcgi_param and moved to fastcgi.erb
This commit is contained in:
parent
a128713520
commit
9bedd7950a
6 changed files with 31 additions and 28 deletions
|
@ -245,7 +245,7 @@ nginx::resource::location { "some_root":
|
|||
ensure => present,
|
||||
location => '/some/url',
|
||||
fastcgi => "127.0.0.1:9000",
|
||||
params => {
|
||||
fastcgi_param => {
|
||||
'APP_ENV' => 'local',
|
||||
},
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
# value of 90 seconds
|
||||
# [*proxy_set_header*] - Array of vhost headers to set
|
||||
# [*fastcgi*] - location of fastcgi (host:port)
|
||||
# [*fastcgi_param*] - Set additional custom fastcgi_params
|
||||
# [*fastcgi_params*] - optional alternative fastcgi_params file to use
|
||||
# [*fastcgi_script*] - optional SCRIPT_FILE parameter
|
||||
# [*fastcgi_split_path*] - Allows settings of fastcgi_split_path_info so
|
||||
|
@ -65,7 +66,6 @@
|
|||
# custom_cfg)
|
||||
# [*try_files*] - An array of file locations to try
|
||||
# [*option*] - Reserved for future use
|
||||
# [*params*] - Set additional custom fastcgi_params
|
||||
# [*proxy_cache*] - This directive sets name of zone for caching.
|
||||
# The same zone can be used in multiple places.
|
||||
# [*proxy_cache_valid*] - This directive sets the time for caching
|
||||
|
@ -115,7 +115,7 @@
|
|||
# www_root => '/var/www/bob',
|
||||
# location => '/bob',
|
||||
# vhost => 'test2.local',
|
||||
# params => {
|
||||
# fastcgi_param => {
|
||||
# 'APP_ENV' => 'local',
|
||||
# }
|
||||
# }
|
||||
|
@ -137,6 +137,7 @@ define nginx::resource::location (
|
|||
$proxy_connect_timeout = $nginx::config::proxy_connect_timeout,
|
||||
$proxy_set_header = $nginx::config::proxy_set_header,
|
||||
$fastcgi = undef,
|
||||
$fastcgi_param = undef,
|
||||
$fastcgi_params = "${nginx::config::conf_dir}/fastcgi_params",
|
||||
$fastcgi_script = undef,
|
||||
$fastcgi_split_path = undef,
|
||||
|
@ -155,7 +156,6 @@ define nginx::resource::location (
|
|||
$location_custom_cfg_prepend = undef,
|
||||
$location_custom_cfg_append = undef,
|
||||
$try_files = undef,
|
||||
$params = undef,
|
||||
$proxy_cache = false,
|
||||
$proxy_cache_valid = false,
|
||||
$proxy_method = undef,
|
||||
|
@ -199,6 +199,9 @@ define nginx::resource::location (
|
|||
if ($fastcgi != undef) {
|
||||
validate_string($fastcgi)
|
||||
}
|
||||
if ($fastcgi_param != undef) {
|
||||
validate_hash($fastcgi_param)
|
||||
}
|
||||
validate_string($fastcgi_params)
|
||||
if ($fastcgi_script != undef) {
|
||||
validate_string($fastcgi_script)
|
||||
|
@ -252,9 +255,6 @@ define nginx::resource::location (
|
|||
if ($try_files != undef) {
|
||||
validate_array($try_files)
|
||||
}
|
||||
if ($params != undef) {
|
||||
validate_hash($params)
|
||||
}
|
||||
if ($proxy_cache != false) {
|
||||
validate_string($proxy_cache)
|
||||
}
|
||||
|
@ -303,8 +303,10 @@ define nginx::resource::location (
|
|||
if (($www_root != undef) and ($proxy != undef)) {
|
||||
fail('Cannot define both directory and proxy in a virtual host')
|
||||
}
|
||||
if (($params != undef) and defined(File[$fastcgi_params])) {
|
||||
fail('Cannot define both custom fastcgi_params and a fastcgi_params template')
|
||||
|
||||
# fastcgi_script is deprecated
|
||||
if ($fastcgi_script != undef) {
|
||||
warning('The $fastcgi_script parameter is deprecated; please use $fastcgi_param instead to define custom fastcgi_params!')
|
||||
}
|
||||
|
||||
# Use proxy or fastcgi template if $proxy is defined, otherwise use directory template.
|
||||
|
|
|
@ -471,26 +471,28 @@ describe 'nginx::resource::location' do
|
|||
end
|
||||
end
|
||||
|
||||
context "when params is {'CUSTOM_PARAM' => 'value'}" do
|
||||
let :params do default_params.merge({ :params => {'CUSTOM_PARAM' => 'value'} }) end
|
||||
it "should set custom fastcgi_params" do
|
||||
should contain_file('/etc/nginx/fastcgi_params').
|
||||
with_content(%r|fastcgi_param\s+CUSTOM_PARAM\s+value;|)
|
||||
context "when fastcgi_param is {'CUSTOM_PARAM' => 'value'}" do
|
||||
let :params do default_params.merge({ :fastcgi_param => {'CUSTOM_PARAM' => 'value', 'CUSTOM_PARAM2' => 'value2'} }) end
|
||||
it "should set fastcgi_param" do
|
||||
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).
|
||||
with_content(%r|fastcgi_param\s+CUSTOM_PARAM\s+value;|).
|
||||
with_content(%r|fastcgi_param\s+CUSTOM_PARAM2\s+value2;|)
|
||||
end
|
||||
it "should add comment # Enable custom fastcgi_params" do
|
||||
should contain_file('/etc/nginx/fastcgi_params').
|
||||
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).
|
||||
with_content(%r|# Enable custom fastcgi_params\s+|)
|
||||
end
|
||||
end
|
||||
|
||||
context "when params is not set" do
|
||||
context "when fastcgi_param is not set" do
|
||||
let :params do default_params end
|
||||
it "should not set custom fastcgi_params" do
|
||||
should contain_file('/etc/nginx/fastcgi_params').
|
||||
without_content(/fastcgi_param\s+CUSTOM_PARAM\s+.+?;/)
|
||||
it "should not set fastcgi_param" do
|
||||
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).
|
||||
without_content(/fastcgi_param\s+CUSTOM_PARAM\s+.+?;/).
|
||||
without_content(/fastcgi_param\s+CUSTOM_PARAM2\s+.+?;/)
|
||||
end
|
||||
it "should not add comment # Enable custom fastcgi_params" do
|
||||
should contain_file('/etc/nginx/fastcgi_params').
|
||||
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).
|
||||
without_content(/# Enable custom fastcgi_params\s+/)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,10 +25,3 @@ fastcgi_param HTTPS $https;
|
|||
|
||||
# PHP only, required if PHP was built with --enable-force-cgi-redirect
|
||||
fastcgi_param REDIRECT_STATUS 200;
|
||||
|
||||
<% if @params %>
|
||||
# Enable custom fastcgi_params
|
||||
<% params.each_pair do |key, val| -%>
|
||||
fastcgi_param <%= key %> <%= val %>;
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
|
|
@ -12,3 +12,9 @@
|
|||
<% if defined? @fastcgi_script %>
|
||||
fastcgi_param SCRIPT_FILENAME <%= @fastcgi_script %>;
|
||||
<% end -%>
|
||||
<% if defined? @fastcgi_param %>
|
||||
# Enable custom fastcgi_params
|
||||
<% fastcgi_param.each_pair do |key, val| -%>
|
||||
fastcgi_param <%= key %> <%= val %>;
|
||||
<% end -%>
|
||||
<% end %>
|
||||
|
|
|
@ -4,7 +4,7 @@ nginx::resource::location { 'www.test.com-params':
|
|||
ensure => present,
|
||||
location => '/some/url',
|
||||
vhost => 'www.test.com',
|
||||
params => {
|
||||
fastcgi_param => {
|
||||
'APP_ENV' => 'production',
|
||||
'APP_VERSION' => '0.1.10',
|
||||
'APP_SECRET' => 'hisfaihicasagfkjsa',
|
||||
|
|
Loading…
Reference in a new issue