nginx.conf.erb 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 %>;
  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. gzip_disable "MSIE [1-6]\.(?!.*SV1)";
  54. <% end -%>
  55. <% if @proxy_cache_path -%>
  56. 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 %>;
  57. <% end -%>
  58. <% if @fastcgi_cache_path -%>
  59. 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 %>;
  60. <% end -%>
  61. <% if @fastcgi_cache_key -%>
  62. fastcgi_cache_key <%= @fastcgi_cache_key %>;
  63. <% end -%>
  64. <% if @fastcgi_cache_use_stale -%>
  65. fastcgi_cache_use_stale <%= @fastcgi_cache_use_stale %>;
  66. <% end -%>
  67. <% if @http_cfg_append -%>
  68. <%- field_width = @http_cfg_append.inject(0) { |l,(k,v)| k.size > l ? k.size : l } -%>
  69. <%- @http_cfg_append.sort_by{|k,v| k}.each do |key,value| -%>
  70. <%- Array(value).each do |asubvalue| -%>
  71. <%= sprintf("%-*s", field_width, key) %> <%= asubvalue %>;
  72. <%- end -%>
  73. <%- end -%>
  74. <% end -%>
  75. include <%= @conf_dir %>/conf.d/*.conf;
  76. include <%= @conf_dir %>/sites-enabled/*;
  77. }
  78. <% if @mail -%>
  79. mail {
  80. include <%= @conf_dir %>/conf.mail.d/*.conf;
  81. }
  82. <% end -%>