2014-06-26 05:40:22 +02:00
<% if @rewrite_www_to_non_www -%>
server {
2015-01-13 17:30:00 +01:00
<%- if @listen_ip.is_a?(Array) then -%>
<%- @listen_ip.each do |ip| -%>
listen <%= ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
<%- end -%>
<%- else -%>
listen <%= @listen_ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
<%- end -%>
<%# check to see if ipv6 support exists in the kernel before applying -%>
<%- if @ipv6_enable && (defined? @ipaddress6) -%>
<%- if @ipv6_listen_ip.is_a?(Array) then -%>
<%- @ipv6_listen_ip.each do |ipv6| -%>
listen [<%= ipv6 %>]:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
<%- end -%>
<%- else -%>
listen [<%= @ipv6_listen_ip %>]:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
<%- end -%>
<%- end -%>
2014-06-26 05:40:22 +02:00
server_name www.<%= @server_name[0].gsub(/^www\./, '') %>;
2015-01-19 17:14:46 +01:00
return 301 https://<%= @server_name[0].gsub(/^www\./, '') %>$request_uri;
2015-01-15 20:40:58 +01:00
<%= scope.function_template(["nginx/vhost/vhost_ssl_settings.erb"]) %>
2014-06-26 05:40:22 +02:00
}
2014-09-12 19:42:51 +02:00
<% end -%>
2011-06-07 00:25:04 +02:00
server {
2015-01-13 17:30:00 +01:00
<%- if @listen_ip.is_a?(Array) then -%>
<%- @listen_ip.each do |ip| -%>
listen <%= ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
<%- end -%>
<%- else -%>
2014-06-02 00:23:07 +02:00
listen <%= @listen_ip %>:<%= @ssl_port %> <% if @ssl_listen_option %>ssl<% end %><% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
2015-01-13 17:30:00 +01:00
<%- end -%>
<%# check to see if ipv6 support exists in the kernel before applying -%>
2014-09-12 19:42:51 +02:00
<%- if @ipv6_enable && (defined? @ipaddress6) -%>
2015-01-13 17:30:00 +01:00
<%- if @ipv6_listen_ip.is_a?(Array) then -%>
<%- @ipv6_listen_ip.each do |ipv6| -%>
listen [<%= ipv6 %>]:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
<%- end -%>
<%- else -%>
listen [<%= @ipv6_listen_ip %>]:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %>;
<%- end -%>
2014-09-12 19:42:51 +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(" ") %>;
2011-06-07 00:25:04 +02:00
2015-01-15 20:40:58 +01:00
<%= scope.function_template(["nginx/vhost/vhost_ssl_settings.erb"]) %>
2013-04-16 18:12:32 +02:00
2015-03-17 17:06:54 +01:00
<% if @maintenance -%>
2015-04-13 20:02:18 +02:00
<%= @maintenance_value %>;
2015-03-17 17:06:54 +01:00
<% end -%>
2015-01-15 20:40:58 +01:00
2014-09-12 19:42:51 +02:00
<% if Array(@resolver).count > 0 -%>
2014-04-03 11:59:47 +02:00
resolver <% Array(@resolver).each do |r| %> <%= r %><% end %>;
2013-12-29 15:48:32 +01:00
<% end -%>
2014-09-12 19:42:51 +02:00
<%- if instance_variables.any? { |iv| iv.to_s.include? 'auth_basic' } -%>
<% if defined? @auth_basic -%>
2013-07-17 20:42:57 +02:00
auth_basic "<%= @auth_basic %>";
2014-09-12 19:42:51 +02:00
<% end -%>
<% if defined? @auth_basic_user_file -%>
2013-08-22 22:44:25 +02:00
auth_basic_user_file "<%= @auth_basic_user_file %>";
2014-09-12 19:42:51 +02:00
<% end -%>
<%- end -%>
<%- if instance_variables.any? { |iv| iv.to_s.include? 'client_' } -%>
<%- if defined? @client_body_timeout -%>
2014-06-25 20:55:26 +02:00
client_body_timeout <%= @client_body_timeout %>;
2014-09-12 19:42:51 +02:00
<%- end -%>
<%- if defined? @client_header_timeout -%>
2014-06-25 20:55:26 +02:00
client_header_timeout <%= @client_header_timeout %>;
2014-09-12 19:42:51 +02:00
<%- end -%>
<%- if defined? @client_max_body_size -%>
2014-05-27 12:38:32 +02:00
client_max_body_size <%= @client_max_body_size %>;
2014-09-12 19:42:51 +02:00
<%- end -%>
2014-05-27 12:38:32 +02:00
<% end -%>
2014-06-25 22:58:55 +02:00
<% if defined? @gzip_types -%>
gzip_types <%= @gzip_types %>;
<% end -%>
2013-12-25 01:13:22 +01:00
<% if @index_files.count > 0 -%>
2014-09-12 19:42:51 +02:00
index <% Array(@index_files).each do |i| %> <%= i %><% end %>;
2013-12-19 00:07:56 +01:00
<% end -%>
2013-06-28 10:12:01 +02:00
2014-06-10 00:49:33 +02:00
access_log <%= @ssl_access_log_real %>;
error_log <%= @ssl_error_log_real %>;
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) -%>
2014-12-17 09:20:24 +01:00
<%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%>
2014-06-26 05:40:22 +02:00
<%- 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 -%>
<% end -%>
<% if @vhost_cfg_ssl_prepend -%>
<%- @vhost_cfg_ssl_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%>
<%- if value.is_a?(Hash) -%>
2014-12-17 09:20:24 +01:00
<%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%>
2014-06-26 05:40:22 +02:00
<%- 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 %>
2014-09-12 19:42:51 +02:00
<% end -%>
2013-09-29 20:53:25 +02:00
<% if @root -%>
root <%= @root %>;
<% end -%>
2014-06-26 05:40:22 +02:00
<% Array(@passenger_cgi_param).each do |key,value| -%>
2013-09-29 20:36:19 +02:00
passenger_set_cgi_param <%= key %> <%= value %>;
2014-06-26 05:40:22 +02:00
<% end -%>
2015-04-29 23:37:58 +02:00
<% Array(@passenger_set_header).each do |key,value| -%>
2015-04-29 18:24:38 +02:00
passenger_set_header <%= key %> <%= value %>;
<% end -%>
2015-04-29 18:33:42 +02:00
<% Array(@passenger_env_var).each do |key,value| -%>
2015-04-29 23:37:58 +02:00
passenger_env_var <%= key %> <%= value %>;
2015-04-29 18:33:42 +02:00
<% end -%>
2014-06-26 05:40:22 +02:00
<% Array(@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 -%>