Skip to content

Commit

Permalink
Merge pull request #162 from jfryman/sanitize_vhost_location
Browse files Browse the repository at this point in the history
Regex replace / in resource::vhost
  • Loading branch information
James Fryman committed Oct 19, 2013
2 parents a2083e4 + 8845838 commit 59cf914
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
# }

define nginx::resource::location (
$location,
$ensure = present,
$location = $name,
$vhost = undef,
$www_root = undef,
$index_files = [
Expand Down Expand Up @@ -128,6 +128,8 @@
default => file,
}

$location_sanitized = regsubst($location, '\/', '_', 'G')

## Check for various error conditions
if ($vhost == undef) {
fail('Cannot create a location reference without attaching to a virtual host')
Expand Down Expand Up @@ -164,7 +166,7 @@

## Create stubs for vHost File Fragment Pattern
if ($ssl_only != true) {
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${priority}-${name}":
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${priority}-${location_sanitized}":
ensure => $ensure_real,
content => $content_real,
}
Expand All @@ -173,15 +175,15 @@
## Only create SSL Specific locations if $ssl is true.
if ($ssl == true) {
$ssl_priority = $priority + 300
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${ssl_priority}-${name}-ssl":
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-${ssl_priority}-${location_sanitized}-ssl":
ensure => $ensure_real,
content => $content_real,
}
}

if ($auth_basic_user_file != undef) {
#Generate htpasswd with provided file-locations
file { "${nginx::params::nx_conf_dir}/${name}_htpasswd":
file { "${nginx::params::nx_conf_dir}/${location_sanitized}_htpasswd":
ensure => $ensure,
mode => '0644',
source => $auth_basic_user_file,
Expand Down

0 comments on commit 59cf914

Please sign in to comment.