2014-06-26 05:40:22 +02:00
|
|
|
<% if @rewrite_www_to_non_www -%>
|
|
|
|
server {
|
|
|
|
listen <%= @listen_ip %>:<%= @listen_port %>;
|
|
|
|
server_name www.<%= @server_name[0].gsub(/^www\./, '') %>;
|
|
|
|
return 301 http://<%= @server_name[0].gsub(/^www\./, '') %>$uri;
|
|
|
|
}
|
|
|
|
|
|
|
|
<% end -%>
|
2011-06-07 00:25:04 +02:00
|
|
|
server {
|
2013-07-17 20:42:57 +02:00
|
|
|
listen <%= @listen_ip %>:<%= @listen_port %><% if @listen_options %> <%= @listen_options %><% end %>;
|
2013-07-08 16:58:05 +02:00
|
|
|
<% # check to see if ipv6 support exists in the kernel before applying %>
|
2013-11-22 05:18:04 +01:00
|
|
|
<% if @ipv6_enable && (defined? @ipaddress6) %>
|
2014-01-27 16:57:38 +01:00
|
|
|
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %>;
|
2013-07-08 16:58:05 +02:00
|
|
|
<% end %>
|
2014-05-13 10:04:46 +02:00
|
|
|
server_name <%= @rewrite_www_to_non_www ? @server_name[0].gsub(/^www\./, '') : @server_name.join(" ") %>;
|
2013-08-05 09:33:36 +02:00
|
|
|
<% if defined? @auth_basic -%>
|
2013-07-17 20:42:57 +02:00
|
|
|
auth_basic "<%= @auth_basic %>";
|
2013-07-08 16:58:05 +02:00
|
|
|
<% end -%>
|
2013-08-31 20:09:58 +02:00
|
|
|
<% if defined? @auth_basic_user_file -%>
|
2013-07-17 20:42:57 +02:00
|
|
|
auth_basic_user_file <%= @auth_basic_user_file %>;
|
2013-07-08 16:58:05 +02:00
|
|
|
<% end -%>
|
2014-06-25 20:55:26 +02:00
|
|
|
<% if defined? @client_body_timeout -%>
|
|
|
|
client_body_timeout <%= @client_body_timeout %>;
|
|
|
|
<% end -%>
|
|
|
|
<% if defined? @client_header_timeout -%>
|
|
|
|
client_header_timeout <%= @client_header_timeout %>;
|
|
|
|
<% end -%>
|
2014-01-28 21:52:56 +01:00
|
|
|
<% if defined? @client_max_body_size -%>
|
|
|
|
client_max_body_size <%= @client_max_body_size %>;
|
|
|
|
<% end -%>
|
2014-06-25 22:58:55 +02:00
|
|
|
<% if defined? @gzip_types -%>
|
|
|
|
gzip_types <%= @gzip_types %>;
|
|
|
|
<% end -%>
|
2013-08-22 21:02:04 +02:00
|
|
|
<%# make sure that allow comes before deny by forcing the allow key (if it -%>
|
|
|
|
<%# exists) to be first in the output order. The hash keys also need to be -%>
|
|
|
|
<%# sorted so that the ordering is stable. -%>
|
2014-06-26 05:40:22 +02:00
|
|
|
<% if @vhost_cfg_prepend -%>
|
|
|
|
<%- @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
|
|
|
|
<%- if value.is_a?(Hash) -%>
|
|
|
|
<%- value.each do |subkey,subvalue| -%>
|
|
|
|
<%- Array(subvalue).each do |asubvalue| -%>
|
2014-03-11 16:09:59 +01:00
|
|
|
<%= key %> <%= subkey %> <%= asubvalue %>;
|
2014-06-26 05:40:22 +02:00
|
|
|
<%- end -%>
|
|
|
|
<%- end -%>
|
|
|
|
<%- else -%>
|
|
|
|
<%- Array(value).each do |asubvalue| -%>
|
2014-03-11 16:09:59 +01:00
|
|
|
<%= key %> <%= asubvalue %>;
|
2014-06-26 05:40:22 +02:00
|
|
|
<%- end -%>
|
|
|
|
<%- end -%>
|
|
|
|
<%- end -%>
|
2014-03-10 10:26:35 +01:00
|
|
|
<% end -%>
|
2014-06-26 05:40:22 +02:00
|
|
|
<% Array(@raw_prepend).each do |line| -%>
|
|
|
|
<%= line %>
|
|
|
|
<% end %>
|
2013-09-29 20:53:25 +02:00
|
|
|
<% if @root -%>
|
|
|
|
root <%= @root %>;
|
|
|
|
<% end -%>
|
2014-06-26 05:40:22 +02:00
|
|
|
<% if @passenger_cgi_param -%>
|
|
|
|
<%- @passenger_cgi_param.keys.sort.each do |key| -%>
|
2014-01-24 13:25:12 +01:00
|
|
|
passenger_set_cgi_param <%= key %> <%= @passenger_cgi_param[key] %>;
|
2014-06-26 05:40:22 +02:00
|
|
|
<%- end -%>
|
|
|
|
<% end -%>
|
2014-05-02 19:17:10 +02:00
|
|
|
<% if @resolver.count > 0 -%>
|
|
|
|
resolver <% Array(@resolver).each do |r| %> <%= r %><% end %>;
|
|
|
|
<% end -%>
|
2013-07-17 20:42:57 +02:00
|
|
|
<% @proxy_set_header.each do |header| -%>
|
2013-07-08 16:58:05 +02:00
|
|
|
proxy_set_header <%= header %>;
|
|
|
|
<% end -%>
|
2014-06-26 05:40:22 +02:00
|
|
|
<% if @add_header -%>
|
|
|
|
<%- @add_header.each do |key,value| -%>
|
2013-12-24 13:07:58 +01:00
|
|
|
add_header <%= key %> <%= value %>;
|
2014-06-26 05:40:22 +02:00
|
|
|
<%- end -%>
|
|
|
|
<% end -%>
|
2013-07-08 16:58:05 +02:00
|
|
|
<% if @rewrite_to_https -%>
|
2013-05-13 10:51:47 +02:00
|
|
|
if ($ssl_protocol = "") {
|
2013-07-08 21:06:02 +02:00
|
|
|
return 301 https://$host$request_uri;
|
2013-05-13 10:51:47 +02:00
|
|
|
}
|
2013-07-08 16:58:05 +02:00
|
|
|
<% end -%>
|
2013-12-25 01:13:22 +01:00
|
|
|
<% if @index_files.count > 0 -%>
|
2013-12-29 16:13:17 +01:00
|
|
|
index <% Array(@index_files).each do |i| %> <%= i %><% end %>;
|
2013-12-19 00:07:56 +01:00
|
|
|
<% end -%>
|
2014-04-18 11:57:31 +02:00
|
|
|
<% if defined? @log_by_lua -%>
|
|
|
|
log_by_lua '<%= @log_by_lua %>';
|
|
|
|
<% end -%>
|
|
|
|
<% if defined? @log_by_lua_file -%>
|
|
|
|
log_by_lua_file "<%= @log_by_lua_file %>";
|
|
|
|
<% end -%>
|
|
|
|
|
2013-08-07 02:40:21 +02:00
|
|
|
access_log <%= @access_log_real %>;
|
|
|
|
error_log <%= @error_log_real %>;
|
2013-07-31 23:07:59 +02:00
|
|
|
|