nginx.conf.erb 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # MANAGED BY PUPPET
  2. <% if @super_user -%>
  3. user <%= @daemon_user %>;
  4. <% end -%>
  5. worker_processes <%= @worker_processes %>;
  6. <% if @worker_rlimit_nofile -%>
  7. worker_rlimit_nofile <%= @worker_rlimit_nofile %>;
  8. <% end -%>
  9. <% if @pid -%>
  10. pid <%= @pid %>;
  11. <% end -%>
  12. error_log <%= @nginx_error_log %> <%= @nginx_error_log_severity %>;
  13. <% if @nginx_cfg_prepend -%>
  14. <%- field_width = @nginx_cfg_prepend.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%>
  15. <%- @nginx_cfg_prepend.sort_by{|k,v| k}.each do |key,value| -%>
  16. <%- Array(value).each do |asubvalue| -%>
  17. <%= sprintf("%-*s", field_width, key) %> <%= asubvalue %>;
  18. <%- end -%>
  19. <%- end -%>
  20. <% end -%>
  21. events {
  22. accept_mutex <%= @accept_mutex %>;
  23. <%- if @accept_mutex_delay -%>
  24. accept_mutex_delay <%= @accept_mutex_delay %>;
  25. <%- end -%>
  26. worker_connections <%= @worker_connections -%>;
  27. <%- if @multi_accept == 'on' -%>
  28. multi_accept on;
  29. <%- end -%>
  30. <%- if @events_use -%>
  31. use <%= @events_use %>;
  32. <%- end -%>
  33. }
  34. http {
  35. include <%= @conf_dir %>/mime.types;
  36. default_type application/octet-stream;
  37. <% if @log_format -%>
  38. <% @log_format.sort_by{|k,v| k}.each do |key,value| -%>
  39. log_format <%= key %> '<%= value %>';
  40. <% end -%>
  41. <% end -%>
  42. access_log <%= @http_access_log %>;
  43. <% if @sendfile == 'on' -%>
  44. sendfile on;
  45. <%- if @http_tcp_nopush == 'on' -%>
  46. tcp_nopush on;
  47. <%- end -%>
  48. <% end -%>
  49. server_tokens <%= @server_tokens %>;
  50. types_hash_max_size <%= @types_hash_max_size %>;
  51. types_hash_bucket_size <%= @types_hash_bucket_size %>;
  52. server_names_hash_bucket_size <%= @names_hash_bucket_size %>;
  53. server_names_hash_max_size <%= @names_hash_max_size %>;
  54. keepalive_timeout <%= @keepalive_timeout %>;
  55. tcp_nodelay <%= @http_tcp_nodelay %>;
  56. <% if @gzip == 'on' -%>
  57. gzip on;
  58. <% if @gzip_buffers -%>
  59. gzip_buffers <%= @gzip_buffers %>;
  60. <% end -%>
  61. gzip_comp_level <%= @gzip_comp_level %>;
  62. <% if @gzip_disable -%>
  63. gzip_disable <%= @gzip_disable %>;
  64. <% end -%>
  65. gzip_min_length <%= @gzip_min_length %>;
  66. gzip_http_version <%= @gzip_http_version %>;
  67. <% if @gzip_proxied -%>
  68. gzip_proxied <%= @gzip_proxied %>;
  69. <% end -%>
  70. <% if @gzip_types -%>
  71. gzip_types <%= @gzip_types.kind_of?(Array) ? @gzip_types.join(' ') : @gzip_types %>;
  72. <% end -%>
  73. gzip_vary <%= @gzip_vary %>;
  74. <% end -%>
  75. <% if @client_body_temp_path -%>
  76. client_body_temp_path <%= @client_body_temp_path %>;
  77. <% end -%>
  78. <% if @client_max_body_size -%>
  79. client_max_body_size <%= @client_max_body_size %>;
  80. <% end -%>
  81. <% if @client_body_buffer_size -%>
  82. client_body_buffer_size <%= @client_body_buffer_size %>;
  83. <% end -%>
  84. <% if @proxy_redirect -%>
  85. proxy_redirect <%= @proxy_redirect %>;
  86. <% end -%>
  87. <% if @proxy_temp_path -%>
  88. proxy_temp_path <%= @proxy_temp_path %>;
  89. <% end -%>
  90. <% if @proxy_connect_timeout -%>
  91. proxy_connect_timeout <%= @proxy_connect_timeout %>;
  92. <% end -%>
  93. <% if @proxy_send_timeout -%>
  94. proxy_send_timeout <%= @proxy_send_timeout %>;
  95. <% end -%>
  96. <% if @proxy_read_timeout -%>
  97. proxy_read_timeout <%= @proxy_read_timeout %>;
  98. <% end -%>
  99. <% if @proxy_buffers -%>
  100. proxy_buffers <%= @proxy_buffers %>;
  101. <% end -%>
  102. <% if @proxy_buffer_size -%>
  103. proxy_buffer_size <%= @proxy_buffer_size %>;
  104. <% end -%>
  105. <% if @proxy_http_version -%>
  106. proxy_http_version <%= @proxy_http_version %>;
  107. <% end -%>
  108. <% @proxy_set_header.each do |header| -%>
  109. proxy_set_header <%= header %>;
  110. <% end -%>
  111. <% @proxy_hide_header.each do |header| -%>
  112. proxy_hide_header <%= header %>;
  113. <% end -%>
  114. <% if @proxy_headers_hash_bucket_size -%>
  115. proxy_headers_hash_bucket_size <%= @proxy_headers_hash_bucket_size %>;
  116. <% end -%>
  117. <% if @proxy_cache_path.is_a?(Hash) -%>
  118. <% @proxy_cache_path.sort_by{|k,v| k}.each do |key,value| -%>
  119. proxy_cache_path <%= key %> keys_zone=<%= value %> levels=<%= @proxy_cache_levels %> max_size=<%= @proxy_cache_max_size %> inactive=<%= @proxy_cache_inactive %><% if @proxy_use_temp_path %> use_temp_path=<%= @proxy_use_temp_path %><% end -%>;
  120. <% end -%>
  121. <% elsif @proxy_cache_path -%>
  122. 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 %><% if @proxy_use_temp_path %> use_temp_path=<%= @proxy_use_temp_path %><% end %>;
  123. <% end -%>
  124. <% if @fastcgi_cache_path -%>
  125. 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 %>;
  126. <% end -%>
  127. <% if @fastcgi_cache_key -%>
  128. fastcgi_cache_key <%= @fastcgi_cache_key %>;
  129. <% end -%>
  130. <% if @fastcgi_cache_use_stale -%>
  131. fastcgi_cache_use_stale <%= @fastcgi_cache_use_stale %>;
  132. <% end -%>
  133. <% if @http_cfg_append -%>
  134. <%- field_width = @http_cfg_append.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%>
  135. <%- @http_cfg_append.sort_by{|k,v| k}.each do |key,value| -%>
  136. <%- Array(value).each do |asubvalue| -%>
  137. <%= sprintf("%-*s", field_width, key) %> <%= asubvalue %>;
  138. <%- end -%>
  139. <%- end -%>
  140. <% end -%>
  141. include <%= @conf_dir %>/conf.d/*.conf;
  142. include <%= @conf_dir %>/sites-enabled/*;
  143. }
  144. <% if @mail -%>
  145. mail {
  146. include <%= @conf_dir %>/conf.mail.d/*.conf;
  147. }
  148. <% end -%>
  149. <% if @stream -%>
  150. stream {
  151. include <%= @conf_dir %>/conf.stream.d/*.conf;
  152. }
  153. <% end -%>