diff --git a/manifests/resource/location.pp b/manifests/resource/location.pp index 614308e1b..d78dd7f74 100644 --- a/manifests/resource/location.pp +++ b/manifests/resource/location.pp @@ -131,6 +131,14 @@ $content_real = template('nginx/vhost/vhost_location_empty.erb') } + if $fastcgi != undef and !defined(File['/etc/nginx/fastcgi_params']) { + file { '/etc/nginx/fastcgi_params': + ensure => present, + mode => '0770', + content => template('nginx/vhost/fastcgi_params.erb'), + } + } + ## Create stubs for vHost File Fragment Pattern if ($ssl_only != true) { file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${priority}-${name}": diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index d9a0f3710..e89da1a40 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -174,6 +174,14 @@ location_cfg_append => $location_cfg_append } } + if $fastcgi != undef and !defined(File['/etc/nginx/fastcgi_params']) { + file { '/etc/nginx/fastcgi_params': + ensure => present, + mode => '0770', + content => template('nginx/vhost/fastcgi_params.erb'), + } + } + # Create a proper file close stub. if ($listen_port != $ssl_port) { file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-699": content => template('nginx/vhost/vhost_footer.erb'), } diff --git a/templates/vhost/vhost_header.erb b/templates/vhost/vhost_header.erb index 6bc0781ed..e4d966f61 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/vhost/vhost_header.erb @@ -5,14 +5,12 @@ server { listen [<%= ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %> ipv6only=on; <% end %> server_name <%= @rewrite_www_to_non_www ? @name.gsub(/^www\./, '') : @server_name.join(" ") %>; - access_log <%= scope.lookupvar('nginx::params::nx_logdir')%>/<%= @name %>.access.log; <% if defined? auth_basic -%> auth_basic "<%= @auth_basic %>"; <% end -%> <% if defined? auth_basic_user_file -%> auth_basic_user_file <%= @auth_basic_user_file %>; <% end -%> - <% @proxy_set_header.each do |header| -%> proxy_set_header <%= header %>; <% end -%> @@ -21,3 +19,7 @@ server { return 301 https://$host$request_uri; } <% end -%> + + access_log <%= scope.lookupvar('nginx::params::nx_logdir')%>/<%= @name.gsub(' ', '_') %>.access.log; + error_log <%= scope.lookupvar('nginx::params::nx_logdir')%>/<%= @name.gsub(' ', '_') %>.error.log; + diff --git a/templates/vhost/vhost_location_alias.erb b/templates/vhost/vhost_location_alias.erb index 76848e496..e2ddbdd28 100644 --- a/templates/vhost/vhost_location_alias.erb +++ b/templates/vhost/vhost_location_alias.erb @@ -5,3 +5,4 @@ <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> <%= key %> <%= value %>;<% end -%><% end -%> } + diff --git a/templates/vhost/vhost_location_directory.erb b/templates/vhost/vhost_location_directory.erb index 9370865a0..61705d345 100644 --- a/templates/vhost/vhost_location_directory.erb +++ b/templates/vhost/vhost_location_directory.erb @@ -2,7 +2,9 @@ <% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> <%= key %> <%= value %>; <% end -%><% end -%> +<% if defined? @www_root -%> root <%= @www_root %>; +<% end -%> <% if @try_files -%> try_files <% @try_files.each do |try| -%> <%= try %> <% end -%>; <% end -%> @@ -19,3 +21,4 @@ <%= key %> <%= value %>; <% end -%><% end -%> } + diff --git a/templates/vhost/vhost_location_empty.erb b/templates/vhost/vhost_location_empty.erb index ce53e1827..aea023cb6 100644 --- a/templates/vhost/vhost_location_empty.erb +++ b/templates/vhost/vhost_location_empty.erb @@ -3,3 +3,4 @@ <%= key %> <%= value %>; <% end -%><% end -%> } + diff --git a/templates/vhost/vhost_location_fastcgi.erb b/templates/vhost/vhost_location_fastcgi.erb index b84badd08..48d9ddb3c 100644 --- a/templates/vhost/vhost_location_fastcgi.erb +++ b/templates/vhost/vhost_location_fastcgi.erb @@ -1,8 +1,17 @@ location <%= @location %> { +<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> + <%= key %> <%= value %>; +<% end -%><% end -%> +<% if defined? @www_root -%> root <%= @www_root %>; +<% end -%> include <%= @fastcgi_params %>; fastcgi_pass <%= @fastcgi %>; -<% unless @fastcgi_script == :undef %> +<% if defined? @fastcgi_script %> fastcgi_param SCRIPT_FILENAME <%= @fastcgi_script %>; <% end -%> +<% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> + <%= key %> <%= value %>; +<% end -%><% end -%> } + diff --git a/templates/vhost/vhost_location_proxy.erb b/templates/vhost/vhost_location_proxy.erb index d06c4e2f9..33fe51495 100644 --- a/templates/vhost/vhost_location_proxy.erb +++ b/templates/vhost/vhost_location_proxy.erb @@ -12,3 +12,4 @@ <%= key %> <%= value %>; <% end -%><% end -%> } + diff --git a/templates/vhost/vhost_location_stub_status.erb b/templates/vhost/vhost_location_stub_status.erb index fdb7a0d19..0827324a9 100644 --- a/templates/vhost/vhost_location_stub_status.erb +++ b/templates/vhost/vhost_location_stub_status.erb @@ -5,3 +5,4 @@ <% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%> <%= key %> <%= value %>;<% end -%><% end -%> } + diff --git a/templates/vhost/vhost_ssl_header.erb b/templates/vhost/vhost_ssl_header.erb index c6b7722a9..1172df14e 100644 --- a/templates/vhost/vhost_ssl_header.erb +++ b/templates/vhost/vhost_ssl_header.erb @@ -14,10 +14,10 @@ server { ssl_protocols <%= @ssl_protocols %>; ssl_ciphers <%= @ssl_ciphers %>; ssl_prefer_server_ciphers on; -<% if @auth_basic != :undef -%> +<% if defined? @auth_basic -%> auth_basic "<%= @auth_basic %>"; <% end -%> -<% if @auth_basic_user_file != :undef -%> +<% if defined? @auth_basic_user_file -%> auth_basic_user_file <%= @auth_basic_user_file %>; <% end -%>