enforce ssl protocoll for a vhost

This commit is contained in:
Arne Hingst 2013-05-13 10:51:47 +02:00
parent 8144b4f27a
commit 3c0c836626
2 changed files with 7 additions and 0 deletions

View file

@ -26,6 +26,7 @@
# [*rewrite_www_to_non_www*] - Adds a server directive and rewrite rule to rewrite www.domain.com to domain.com in order to avoid
# duplicate content (SEO);
# [*try_files*] - Specifies the locations for files to be checked as an array. Cannot be used in conjuction with $proxy.
# [*rewrite_to_https*] - Adds a server directive and rewrite rule to rewrite to ssl
#
# Actions:
#
@ -62,6 +63,7 @@ define nginx::resource::vhost (
$server_name = [$name],
$www_root = undef,
$rewrite_www_to_non_www = false,
$rewrite_to_https = undef,
$location_cfg_prepend = undef,
$location_cfg_append = undef,
$try_files = undef) {

View file

@ -9,3 +9,8 @@ server {
<% proxy_set_header.each do |header| %>
proxy_set_header <%= header %>;<% end %>
<% if @rewrite_to_https %>
if ($ssl_protocol = "") {
return 301 https://$host$request_uri ;
}
<% end %>