diff --git a/manifests/config.pp b/manifests/config.pp index fdaef5953..b1a5466cb 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -14,33 +14,40 @@ # # This class file is not called directly class nginx::config( - $worker_processes = $nginx::params::nx_worker_processes, - $worker_connections = $nginx::params::nx_worker_connections, - $worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile, - $confd_purge = $nginx::params::nx_confd_purge, - $vhost_purge = $nginx::params::nx_vhost_purge, - $server_tokens = $nginx::params::nx_server_tokens, - $proxy_set_header = $nginx::params::nx_proxy_set_header, - $proxy_cache_path = $nginx::params::nx_proxy_cache_path, - $proxy_cache_levels = $nginx::params::nx_proxy_cache_levels, - $proxy_cache_keys_zone = $nginx::params::nx_proxy_cache_keys_zone, - $proxy_cache_max_size = $nginx::params::nx_proxy_cache_max_size, - $proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive, - $proxy_http_version = $nginx::params::nx_proxy_http_version, - $names_hash_bucket_size = $nginx::params::nx_names_hash_bucket_size, - $names_hash_max_size = $nginx::params::nx_names_hash_max_size, - $types_hash_max_size = $nginx::params::nx_types_hash_max_size, - $types_hash_bucket_size = $nginx::params::nx_types_hash_bucket_size, - $client_max_body_size = $nginx::params::nx_client_max_body_size, - $proxy_buffers = $nginx::params::nx_proxy_buffers, - $http_cfg_append = $nginx::params::nx_http_cfg_append, - $nginx_error_log = $nginx::params::nx_nginx_error_log, - $http_access_log = $nginx::params::nx_http_access_log, - $proxy_buffer_size = $nginx::params::nx_proxy_buffer_size, - $gzip = $nginx::params::nx_gzip, - $conf_template = $nginx::params::nx_conf_template, - $proxy_conf_template = $nginx::params::nx_proxy_conf_template, - $proxy_redirect = $nginx::params::nx_proxy_redirect, + $worker_processes = $nginx::params::nx_worker_processes, + $worker_connections = $nginx::params::nx_worker_connections, + $worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile, + $confd_purge = $nginx::params::nx_confd_purge, + $vhost_purge = $nginx::params::nx_vhost_purge, + $server_tokens = $nginx::params::nx_server_tokens, + $proxy_set_header = $nginx::params::nx_proxy_set_header, + $proxy_cache_path = $nginx::params::nx_proxy_cache_path, + $proxy_cache_levels = $nginx::params::nx_proxy_cache_levels, + $proxy_cache_keys_zone = $nginx::params::nx_proxy_cache_keys_zone, + $proxy_cache_max_size = $nginx::params::nx_proxy_cache_max_size, + $proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive, + $fastcgi_cache_path = $nginx::params::nx_fastcgi_cache_path, + $fastcgi_cache_levels = $nginx::params::nx_fastcgi_cache_levels, + $fastcgi_cache_keys_zone = $nginx::params::nx_fastcgi_cache_keys_zone, + $fastcgi_cache_max_size = $nginx::params::nx_fastcgi_cache_max_size, + $fastcgi_cache_inactive = $nginx::params::nx_fastcgi_cache_inactive, + $fastcgi_cache_key = $nginx::params::nx_fastcgi_cache_key, + $fastcgi_cache_use_stale = $nginx::params::nx_fastcgi_cache_use_stale, + $proxy_http_version = $nginx::params::nx_proxy_http_version, + $names_hash_bucket_size = $nginx::params::nx_names_hash_bucket_size, + $names_hash_max_size = $nginx::params::nx_names_hash_max_size, + $types_hash_max_size = $nginx::params::nx_types_hash_max_size, + $types_hash_bucket_size = $nginx::params::nx_types_hash_bucket_size, + $client_max_body_size = $nginx::params::nx_client_max_body_size, + $proxy_buffers = $nginx::params::nx_proxy_buffers, + $http_cfg_append = $nginx::params::nx_http_cfg_append, + $nginx_error_log = $nginx::params::nx_nginx_error_log, + $http_access_log = $nginx::params::nx_http_access_log, + $proxy_buffer_size = $nginx::params::nx_proxy_buffer_size, + $gzip = $nginx::params::nx_gzip, + $conf_template = $nginx::params::nx_conf_template, + $proxy_conf_template = $nginx::params::nx_proxy_conf_template, + $proxy_redirect = $nginx::params::nx_proxy_redirect, ) inherits nginx::params { File { diff --git a/manifests/init.pp b/manifests/init.pp index 3d67aa256..8c18db3ee 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -29,43 +29,50 @@ # include nginx # } class nginx ( - $worker_processes = $nginx::params::nx_worker_processes, - $worker_connections = $nginx::params::nx_worker_connections, - $worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile, - $package_name = $nginx::params::package_name, - $package_ensure = $nginx::params::package_ensure, - $package_source = $nginx::params::package_source, - $proxy_set_header = $nginx::params::nx_proxy_set_header, - $proxy_http_version = $nginx::params::nx_proxy_http_version, - $confd_purge = $nginx::params::nx_confd_purge, - $vhost_purge = $nginx::params::nx_vhost_purge, - $proxy_cache_path = $nginx::params::nx_proxy_cache_path, - $proxy_cache_levels = $nginx::params::nx_proxy_cache_levels, - $proxy_cache_keys_zone = $nginx::params::nx_proxy_cache_keys_zone, - $proxy_cache_max_size = $nginx::params::nx_proxy_cache_max_size, - $proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive, - $configtest_enable = $nginx::params::nx_configtest_enable, - $service_restart = $nginx::params::nx_service_restart, - $service_ensure = $nginx::params::nx_service_ensure, - $mail = $nginx::params::nx_mail, - $server_tokens = $nginx::params::nx_server_tokens, - $client_max_body_size = $nginx::params::nx_client_max_body_size, - $names_hash_bucket_size = $nginx::params::nx_names_hash_bucket_size, - $names_hash_max_size = $nginx::params::nx_names_hash_max_size, - $proxy_buffers = $nginx::params::nx_proxy_buffers, - $proxy_buffer_size = $nginx::params::nx_proxy_buffer_size, - $http_cfg_append = $nginx::params::nx_http_cfg_append, - $nginx_error_log = $nginx::params::nx_nginx_error_log, - $http_access_log = $nginx::params::nx_http_access_log, - $gzip = $nginx::params::nx_gzip, - $conf_template = $nginx::params::nx_conf_template, - $proxy_conf_template = $nginx::params::nx_proxy_conf_template, - $proxy_redirect = $nginx::params::nx_proxy_redirect, - $nginx_vhosts = {}, - $nginx_upstreams = {}, - $nginx_locations = {}, - $nginx_mailhosts = {}, - $manage_repo = $nginx::params::manage_repo, + $worker_processes = $nginx::params::nx_worker_processes, + $worker_connections = $nginx::params::nx_worker_connections, + $worker_rlimit_nofile = $nginx::params::nx_worker_rlimit_nofile, + $package_name = $nginx::params::package_name, + $package_ensure = $nginx::params::package_ensure, + $package_source = $nginx::params::package_source, + $proxy_set_header = $nginx::params::nx_proxy_set_header, + $proxy_http_version = $nginx::params::nx_proxy_http_version, + $confd_purge = $nginx::params::nx_confd_purge, + $vhost_purge = $nginx::params::nx_vhost_purge, + $proxy_cache_path = $nginx::params::nx_proxy_cache_path, + $proxy_cache_levels = $nginx::params::nx_proxy_cache_levels, + $proxy_cache_keys_zone = $nginx::params::nx_proxy_cache_keys_zone, + $proxy_cache_max_size = $nginx::params::nx_proxy_cache_max_size, + $proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive, + $fastcgi_cache_path = $nginx::params::nx_fastcgi_cache_path, + $fastcgi_cache_levels = $nginx::params::nx_fastcgi_cache_levels, + $fastcgi_cache_keys_zone = $nginx::params::nx_fastcgi_cache_keys_zone, + $fastcgi_cache_max_size = $nginx::params::nx_fastcgi_cache_max_size, + $fastcgi_cache_inactive = $nginx::params::nx_fastcgi_cache_inactive, + $fastcgi_cache_key = $nginx::params::nx_fastcgi_cache_key, + $fastcgi_cache_use_stale = $nginx::params::nx_fastcgi_cache_use_stale, + $configtest_enable = $nginx::params::nx_configtest_enable, + $service_restart = $nginx::params::nx_service_restart, + $service_ensure = $nginx::params::nx_service_ensure, + $mail = $nginx::params::nx_mail, + $server_tokens = $nginx::params::nx_server_tokens, + $client_max_body_size = $nginx::params::nx_client_max_body_size, + $names_hash_bucket_size = $nginx::params::nx_names_hash_bucket_size, + $names_hash_max_size = $nginx::params::nx_names_hash_max_size, + $proxy_buffers = $nginx::params::nx_proxy_buffers, + $proxy_buffer_size = $nginx::params::nx_proxy_buffer_size, + $http_cfg_append = $nginx::params::nx_http_cfg_append, + $nginx_error_log = $nginx::params::nx_nginx_error_log, + $http_access_log = $nginx::params::nx_http_access_log, + $gzip = $nginx::params::nx_gzip, + $conf_template = $nginx::params::nx_conf_template, + $proxy_conf_template = $nginx::params::nx_proxy_conf_template, + $proxy_redirect = $nginx::params::nx_proxy_redirect, + $nginx_vhosts = {}, + $nginx_upstreams = {}, + $nginx_locations = {}, + $nginx_mailhosts = {}, + $manage_repo = $nginx::params::manage_repo, ) inherits nginx::params { include stdlib @@ -95,6 +102,23 @@ validate_string($proxy_cache_keys_zone) validate_string($proxy_cache_max_size) validate_string($proxy_cache_inactive) + + if ($fastcgi_cache_path != false) { + validate_string($fastcgi_cache_path) + } + if (!is_integer($fastcgi_cache_levels)) { + fail('$fastcgi_cache_levels must be an integer.') + } + validate_string($fastcgi_cache_keys_zone) + validate_string($fastcgi_cache_max_size) + validate_string($fastcgi_cache_inactive) + if ($fastcgi_cache_key != false) { + validate_string($fastcgi_cache_key) + } + if ($fastcgi_cache_use_stale != false) { + validate_string($fastcgi_cache_use_stale) + } + validate_bool($configtest_enable) validate_string($service_restart) validate_bool($mail) @@ -128,33 +152,40 @@ } class { 'nginx::config': - worker_processes => $worker_processes, - worker_connections => $worker_connections, - worker_rlimit_nofile => $worker_rlimit_nofile, - proxy_set_header => $proxy_set_header, - proxy_http_version => $proxy_http_version, - proxy_cache_path => $proxy_cache_path, - proxy_cache_levels => $proxy_cache_levels, - proxy_cache_keys_zone => $proxy_cache_keys_zone, - proxy_cache_max_size => $proxy_cache_max_size, - proxy_cache_inactive => $proxy_cache_inactive, - confd_purge => $confd_purge, - vhost_purge => $vhost_purge, - server_tokens => $server_tokens, - client_max_body_size => $client_max_body_size, - names_hash_bucket_size => $names_hash_bucket_size, - names_hash_max_size => $names_hash_max_size, - proxy_buffers => $proxy_buffers, - proxy_buffer_size => $proxy_buffer_size, - http_cfg_append => $http_cfg_append, - nginx_error_log => $nginx_error_log, - http_access_log => $http_access_log, - gzip => $gzip, - conf_template => $conf_template, - proxy_conf_template => $proxy_conf_template, - proxy_redirect => $proxy_redirect, - require => Class['nginx::package'], - notify => Class['nginx::service'], + worker_processes => $worker_processes, + worker_connections => $worker_connections, + worker_rlimit_nofile => $worker_rlimit_nofile, + proxy_set_header => $proxy_set_header, + proxy_http_version => $proxy_http_version, + proxy_cache_path => $proxy_cache_path, + proxy_cache_levels => $proxy_cache_levels, + proxy_cache_keys_zone => $proxy_cache_keys_zone, + proxy_cache_max_size => $proxy_cache_max_size, + proxy_cache_inactive => $proxy_cache_inactive, + fastcgi_cache_path => $fastcgi_cache_path, + fastcgi_cache_levels => $fastcgi_cache_levels, + fastcgi_cache_keys_zone => $fastcgi_cache_keys_zone, + fastcgi_cache_max_size => $fastcgi_cache_max_size, + fastcgi_cache_inactive => $fastcgi_cache_inactive, + fastcgi_cache_key => $fastcgi_cache_key, + fastcgi_cache_use_stale => $fastcgi_cache_use_stale, + confd_purge => $confd_purge, + vhost_purge => $vhost_purge, + server_tokens => $server_tokens, + client_max_body_size => $client_max_body_size, + names_hash_bucket_size => $names_hash_bucket_size, + names_hash_max_size => $names_hash_max_size, + proxy_buffers => $proxy_buffers, + proxy_buffer_size => $proxy_buffer_size, + http_cfg_append => $http_cfg_append, + nginx_error_log => $nginx_error_log, + http_access_log => $http_access_log, + gzip => $gzip, + conf_template => $conf_template, + proxy_conf_template => $proxy_conf_template, + proxy_redirect => $proxy_redirect, + require => Class['nginx::package'], + notify => Class['nginx::service'], } class { 'nginx::service': diff --git a/manifests/params.pp b/manifests/params.pp index 8ecf10154..94dd1938b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -53,6 +53,14 @@ $nx_proxy_cache_max_size = '500m' $nx_proxy_cache_inactive = '20m' + $nx_fastcgi_cache_path = false + $nx_fastcgi_cache_levels = 1 + $nx_fastcgi_cache_keys_zone = 'd3:100m' + $nx_fastcgi_cache_max_size = '500m' + $nx_fastcgi_cache_inactive = '20m' + $nx_fastcgi_cache_key = false + $nx_fastcgi_cache_use_stale = false + $nx_client_body_temp_path = "${nx_run_dir}/client_body_temp" $nx_client_body_buffer_size = '128k' $nx_client_max_body_size = '10m' diff --git a/templates/conf.d/nginx.conf.erb b/templates/conf.d/nginx.conf.erb index 62e49e2a3..f9de20043 100644 --- a/templates/conf.d/nginx.conf.erb +++ b/templates/conf.d/nginx.conf.erb @@ -39,6 +39,16 @@ http { proxy_cache_path <%= @proxy_cache_path %> levels=<%= @proxy_cache_levels %> keys_zone=<%= @proxy_cache_keys_zone %> max_size=<%= @proxy_cache_max_size %> inactive=<%= @proxy_cache_inactive %>; <% end -%> +<% if @fastcgi_cache_path -%> + fastcgi_cache_path <%= @fastcgi_cache_path %> levels=<%= @fastcgi_cache_levels %> keys_zone=<%= @fastcgi_cache_keys_zone %> max_size=<%= @fastcgi_cache_max_size %> inactive=<%= @fastcgi_cache_inactive %>; +<% end -%> +<% if @fastcgi_cache_key -%> + fastcgi_cache_key <%= @fastcgi_cache_key %>; +<% end -%> +<% if @fastcgi_cache_use_stale -%> + fastcgi_cache_use_stale <%= @fastcgi_cache_use_stale %>; +<% end -%> + <% if @http_cfg_append -%><% @http_cfg_append.sort_by{|k,v| k}.each do |key,value| -%> <%= key %> <%= value %>; <% end -%>