Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rewrite_to_https_port setting support #789

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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