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 ssl_proxy variable #5

Closed
wants to merge 3 commits 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
20 changes: 15 additions & 5 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# [*index_files*] - Default index files for NGINX to read when traversing a directory
# [*proxy*] - Proxy server(s) for a location to connect to. Accepts a single value, can be used in conjunction
# with nginx::resource::upstream
# [*ssl_proxy*] - Proxy server(s) for a location to connect to for SSL vHosts. Accepts a single value, can be used in conjunction
# with nginx::resource::upstream
# [*ssl*] - Indicates whether to setup SSL bindings for this location.
# [*option*] - Reserved for future use
#
Expand All @@ -25,12 +27,13 @@
# vhost => 'test2.local',
# }
define nginx::resource::location(
$location,
$ensure = 'present',
$vhost = undef,
$location,
$www_root = undef,
$index_files = ['index.html', 'index.htm', 'index.php'],
$proxy = undef,
$ssl_proxy = undef,
$ssl = 'false',
$option = undef
){
Expand All @@ -53,6 +56,13 @@
} else {
$content_real = template('nginx/vhost/vhost_location_directory.erb')
}

# check if ssl is enabled AND a different proxy is assigned
if (($ssl == 'true') and ($ssl_proxy != undef)) {
$content_ssl_real = template('nginx/vhost/vhost_location_ssl_proxy.erb')
} else {
$content_ssl_real = template('nginx/vhost/vhost_location_proxy.erb')
}

## Check for various error condtiions
if ($vhost == undef) {
Expand All @@ -74,9 +84,9 @@

## Only create SSL Specific locations if $ssl is true.
if ($ssl == 'true') {
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-800-${name}-ssl":
ensure => $ensure_real,
content => $content_real,
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-800-${name}-ssl":
ensure => $ensure_real,
content => $content_ssl_real,
}
}
}
}
6 changes: 5 additions & 1 deletion manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# [*index_files*] - Default index files for NGINX to read when traversing a directory
# [*proxy*] - Proxy server(s) for a location to connect to. Accepts a single value, can be used in conjunction
# with nginx::resource::upstream
# [*ssl_proxy*] - Proxy server(s) for a location to connect to for SSL vHosts. Accepts a single value, can be used in conjunction
# with nginx::resource::upstream
# [*ssl*] - Indicates whether to setup SSL bindings for this location.
# [*ssl_cert*] - Pre-generated SSL Certificate file to reference for SSL Support. This is not generated by this module.
# [*ssl_key*] - Pre-generated SSL Key file to reference for SSL Support. This is not generated by this module.
Expand Down Expand Up @@ -40,6 +42,7 @@
$ssl = 'false',
$ssl_cert = undef,
$ssl_key = undef,
$ssl_proxy = undef,
$proxy = undef,
$index_files = ['index.html', 'index.htm', 'index.php'],
$www_root = undef
Expand Down Expand Up @@ -82,6 +85,7 @@
ssl => $ssl,
location => '/',
proxy => $proxy,
ssl_proxy => $ssl_proxy,
www_root => $www_root,
notify => Class['nginx::service'],
}
Expand Down Expand Up @@ -115,4 +119,4 @@
notify => Class['nginx::service'],
}
}
}
}
4 changes: 4 additions & 0 deletions templates/vhost/vhost_location_ssl_proxy.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
location <%= location %> {
proxy_pass <%= ssl_proxy %>;
}