Skip to content

Commit

Permalink
Add rewrite_to_https_port setting support
Browse files Browse the repository at this point in the history
  • Loading branch information
invidian committed May 12, 2016
1 parent 091397c commit 25b1f4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
# put before everything else inside vhost ssl
# [*rewrite_to_https*] - Adds a server directive and rewrite rule to
# rewrite to ssl
# [*rewrite_to_https_port*] - Add https port to rewrite. Useful, when nginx
# SSL is behind port multiplexer. Default to 8443
# [*include_files*] - Adds include files to vhost
# [*access_log*] - Where to write access log. May add additional
# options like log format to the end.
Expand Down Expand Up @@ -235,6 +237,7 @@
$www_root = undef,
$rewrite_www_to_non_www = false,
$rewrite_to_https = undef,
$rewrite_to_https_port = 8443,
$location_custom_cfg = undef,
$location_cfg_prepend = undef,
$location_cfg_append = undef,
Expand Down Expand Up @@ -411,6 +414,12 @@
if ($rewrite_to_https != undef) {
validate_bool($rewrite_to_https)
}
if is_string($rewrite_to_https_port) {
warning('DEPRECATION: String $rewrite_to_https_port must be converted to an integer. Integer string support will be removed in a future release.')
}
elsif !is_integer($rewrite_to_https_port) {
fail('$rewrite_to_https_port must be an integer.')
}
if ($raw_prepend != undef) {
if (is_array($raw_prepend)) {
validate_array($raw_prepend)
Expand Down
2 changes: 1 addition & 1 deletion templates/vhost/vhost_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ server {
<% end -%>
<% if @rewrite_to_https -%>
if ($ssl_protocol = "") {
return 301 https://$host<% if @ssl_port.to_i != 443 %>:<%= @ssl_port %><% end %>$request_uri;
return 301 https://$host<% if @rewrite_to_https_port %><% if @rewrite_to_https_port.to_i != 443 %>:<%= @rewrite_to_https_port %><% end %><% elsif @ssl_port.to_i != 443 %>:<%= @ssl_port %><% end %>$request_uri;
}
<% end -%>
<% if @index_files.count > 0 -%>
Expand Down

0 comments on commit 25b1f4b

Please sign in to comment.