params.pp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # Class: nginx::param
  2. #
  3. # This module manages NGINX paramaters
  4. #
  5. # Parameters:
  6. #
  7. # There are no default parameters for this class.
  8. #
  9. # Actions:
  10. #
  11. # Requires:
  12. #
  13. # Sample Usage:
  14. #
  15. # This class file is not called directly
  16. class nginx::params {
  17. $nx_temp_dir = '/tmp'
  18. $nx_run_dir = '/var/nginx'
  19. $nx_conf_template = 'nginx/conf.d/nginx.conf.erb'
  20. $nx_proxy_conf_template = 'nginx/conf.d/proxy.conf.erb'
  21. $nx_confd_purge = false
  22. $nx_vhost_purge = false
  23. $nx_worker_processes = 1
  24. $nx_worker_connections = 1024
  25. $nx_worker_rlimit_nofile = 1024
  26. $nx_types_hash_max_size = 1024
  27. $nx_types_hash_bucket_size = 512
  28. $nx_names_hash_bucket_size = 64
  29. $nx_names_hash_max_size = 512
  30. $nx_multi_accept = off
  31. # One of [kqueue|rtsig|epoll|/dev/poll|select|poll|eventport]
  32. # or false to use OS default
  33. $nx_events_use = false
  34. $nx_sendfile = on
  35. $nx_keepalive_timeout = 65
  36. $nx_http_tcp_nodelay = on
  37. $nx_http_tcp_nopush = off
  38. $nx_gzip = on
  39. $nx_server_tokens = on
  40. $nx_spdy = off
  41. $nx_ssl_stapling = off
  42. $nx_proxy_redirect = off
  43. $nx_proxy_set_header = [
  44. 'Host $host',
  45. 'X-Real-IP $remote_addr',
  46. 'X-Forwarded-For $proxy_add_x_forwarded_for',
  47. ]
  48. $nx_proxy_cache_path = false
  49. $nx_proxy_cache_levels = '1'
  50. $nx_proxy_cache_keys_zone = 'd2:100m'
  51. $nx_proxy_cache_max_size = '500m'
  52. $nx_proxy_cache_inactive = '20m'
  53. $nx_fastcgi_cache_path = false
  54. $nx_fastcgi_cache_levels = '1'
  55. $nx_fastcgi_cache_keys_zone = 'd3:100m'
  56. $nx_fastcgi_cache_max_size = '500m'
  57. $nx_fastcgi_cache_inactive = '20m'
  58. $nx_fastcgi_cache_key = false
  59. $nx_fastcgi_cache_use_stale = false
  60. $nx_client_body_temp_path = "${nx_run_dir}/client_body_temp"
  61. $nx_client_body_buffer_size = '128k'
  62. $nx_client_max_body_size = '10m'
  63. $nx_proxy_temp_path = "${nx_run_dir}/proxy_temp"
  64. $nx_proxy_connect_timeout = '90'
  65. $nx_proxy_send_timeout = '90'
  66. $nx_proxy_read_timeout = '90'
  67. $nx_proxy_buffers = '32 4k'
  68. $nx_proxy_http_version = '1.0'
  69. $nx_proxy_buffer_size = '8k'
  70. $nx_proxy_headers_hash_bucket_size = '64'
  71. $nx_logdir = '/var/log/nginx'
  72. $nx_pid = $::kernel ? {
  73. /(?i-mx:linux)/ => $::osfamily ? {
  74. # archlinux has hardcoded pid in service file to /run/nginx.pid, setting
  75. # it will prevent nginx from starting
  76. /(?i-mx:archlinux)/ => false,
  77. default => '/var/run/nginx.pid',
  78. },
  79. /(?i-mx:sunos)/ => '/var/run/nginx.pid',
  80. /(?i-mx:freebsd)/ => '/var/run/nginx.pid',
  81. }
  82. $nx_conf_dir = $::kernelversion ? {
  83. /(?i-mx:joyent)/ => '/opt/local/etc/nginx',
  84. default => $::kernel ? {
  85. /(?i-mx:freebsd)/ => '/usr/local/etc/nginx',
  86. default => '/etc/nginx',
  87. }
  88. }
  89. if $::osfamily {
  90. $solaris_nx_daemon_user = $::kernelversion ? {
  91. /(?i-mx:joyent)/ => 'www',
  92. default => 'webservd',
  93. }
  94. $nx_daemon_user = $::osfamily ? {
  95. /(?i-mx:archlinux)/ => 'http',
  96. /(?i-mx:redhat|suse|gentoo|linux)/ => 'nginx',
  97. /(?i-mx:debian)/ => 'www-data',
  98. /(?i-mx:solaris)/ => $solaris_nx_daemon_user,
  99. /(?i-mx:freebsd)/ => 'www',
  100. }
  101. } else {
  102. warning('$::osfamily not defined. Support for $::operatingsystem is deprecated')
  103. warning("Please upgrade from facter ${::facterversion} to >= 1.7.2")
  104. $nx_daemon_user = $::operatingsystem ? {
  105. /(?i-mx:archlinux)/ => 'http',
  106. /(?i-mx:debian|ubuntu)/ => 'www-data',
  107. /(?i-mx:fedora|rhel|redhat|centos|scientific|suse|opensuse|amazon|gentoo|oraclelinux)/ => 'nginx',
  108. /(?i-mx:solaris)/ => 'webservd',
  109. /(?i-mx:freebsd)/ => 'www',
  110. }
  111. }
  112. $root_group = $::operatingsystem ? {
  113. 'FreeBSD' => 'wheel',
  114. default => 'root',
  115. }
  116. # Nginx is default launched as root if not change this parameter
  117. $nx_super_user = true
  118. # Service restart after Nginx 0.7.53 could also be just
  119. # "/path/to/nginx/bin -s HUP" Some init scripts do a configtest, some don't.
  120. # If configtest_enable it's true then service restart will take
  121. # $nx_service_restart value, forcing configtest.
  122. $nx_configtest_enable = false
  123. $nx_service_restart = '/etc/init.d/nginx configtest && /etc/init.d/nginx restart'
  124. $nx_service_ensure = running
  125. $nx_mail = false
  126. $nx_http_cfg_append = false
  127. $nx_nginx_error_log = "${nx_logdir}/error.log"
  128. $nx_http_access_log = "${nx_logdir}/access.log"
  129. # package name depends on distribution, e.g. for Debian nginx-full | nginx-light
  130. $package_name = 'nginx'
  131. $package_ensure = 'present'
  132. $package_source = 'nginx'
  133. $manage_repo = true
  134. # Specific owner for sites-available directory
  135. $sites_available_owner = 'root'
  136. $sites_available_group = $root_group
  137. $sites_available_mode = '0644'
  138. # Owner for all other files
  139. $global_owner = 'root'
  140. $global_group = $root_group
  141. $global_mode = '0644'
  142. }