module-nginx/templates/vhost/vhost_header.erb

57 lines
2.2 KiB
Text
Raw Normal View History

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 %>;
<% # check to see if ipv6 support exists in the kernel before applying %>
<% if @ipv6_enable && (defined? @ipaddress6) %>
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %>;
<% end %>
2013-07-17 20:42:57 +02:00
server_name <%= @rewrite_www_to_non_www ? @name.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 %>";
<% 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 %>;
<% end -%>
2014-01-28 21:52:56 +01:00
<% if defined? @client_max_body_size -%>
client_max_body_size <%= @client_max_body_size %>;
<% end -%>
<%# 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. -%>
2013-11-10 23:59:11 +01: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(subkey).each do |asubkey| -%>
<% Array(subvalue).each do |asubvalue| -%>
<%= key %> <%= asubkey %> <%= asubvalue %>;
<% end %>
2014-03-09 20:46:13 +01:00
<% end %>
<% end -%><% else -%>
<% Array(value).each do |sub| -%>
<%= key %> <%= sub %>;
<% end %>
<% end -%>
2013-09-05 09:43:44 +02:00
<% end -%><% end -%>
<% if @root -%>
root <%= @root %>;
<% end -%>
<% if @passenger_cgi_param -%><% @passenger_cgi_param.keys.sort.each do |key| -%>
passenger_set_cgi_param <%= key %> <%= @passenger_cgi_param[key] %>;
<% end -%><% end -%>
2013-07-17 20:42:57 +02:00
<% @proxy_set_header.each do |header| -%>
proxy_set_header <%= header %>;
<% end -%>
<% if @add_header -%><% @add_header.each do |key,value| -%>
add_header <%= key %> <%= value %>;
<% end -%><% end -%>
<% 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
}
<% end -%>
<% if @index_files.count > 0 -%>
index <% Array(@index_files).each do |i| %> <%= i %><% end %>;
<% end -%>
access_log <%= @access_log_real %>;
error_log <%= @error_log_real %>;