nginx.conf.erb 4.9 KB

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