diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index dab55ca..88fa1da 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -211,7 +211,7 @@ define nginx::resource::vhost ( 'absent' => absent, default => 'file', }, - content => template('nginx/vhost/vhost_footer.erb'), + content => template('nginx/vhost/vhost_ssl_footer.erb'), notify => Class['nginx::service'], } diff --git a/templates/vhost/vhost_ssl_footer.erb b/templates/vhost/vhost_ssl_footer.erb new file mode 100644 index 0000000..2a203ee --- /dev/null +++ b/templates/vhost/vhost_ssl_footer.erb @@ -0,0 +1,15 @@ +<% if @include_files %><% @include_files.each do |file| -%> +include <%= file %>; +<% end -%><% end -%> +<% if @vhost_cfg_append -%><% vhost_cfg_append.each do |key,value| -%> + <%= key %> <%= value %>; +<% end -%> +<% end -%> +} +<% if @rewrite_www_to_non_www -%> +server { + listen <%= @listen_ip %>:<%= @ssl_port %> ssl; + server_name www.<%= @name.gsub(/^www\./, '') %>; + rewrite ^ https://<%= @name.gsub(/^www\./, '') %>$uri permanent; +} +<% end %>