Skip to content

Commit

Permalink
Merge pull request #209 from abraham1901/dev
Browse files Browse the repository at this point in the history
Bugfix: Fixed long names virtual hosts
  • Loading branch information
James Fryman committed Dec 24, 2013
2 parents 5661806 + d9d7783 commit 69b77d7
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions manifests/resource/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@
'absent' => absent,
default => 'link',
}
$config_file = "${vhost_dir}/${name}.conf"

$name_sanitized = regsubst($name, ' ', '_', 'G')
$config_file = "${vhost_dir}/${name_sanitized}.conf"

File {
ensure => $ensure ? {
Expand Down Expand Up @@ -188,13 +190,12 @@
# This was a lot to add up in parameter list so add it down here
# Also opted to add more logic here and keep template cleaner which
# unfortunately means resorting to the $varname_real thing
$domain_log_name = regsubst($name, ' ', '_', 'G')
$access_log_real = $access_log ? {
undef => "${nginx::params::nx_logdir}/${domain_log_name}.access.log",
undef => "${nginx::params::nx_logdir}/${name_sanitized}.access.log",
default => $access_log,
}
$error_log_real = $error_log ? {
undef => "${nginx::params::nx_logdir}/${domain_log_name}.error.log",
undef => "${nginx::params::nx_logdir}/${name_sanitized}.error.log",
default => $error_log,
}

Expand All @@ -211,9 +212,9 @@

if $use_default_location == true {
# Create the default location reference for the vHost
nginx::resource::location {"${name}-default":
nginx::resource::location {"${name_sanitized}-default":
ensure => $ensure,
vhost => $name,
vhost => $name_sanitized,
ssl => $ssl,
ssl_only => $ssl_only,
location => '/',
Expand All @@ -240,12 +241,12 @@

# Support location_cfg_prepend and location_cfg_append on default location created by vhost
if $location_cfg_prepend {
Nginx::Resource::Location["${name}-default"] {
Nginx::Resource::Location["${name_sanitized}-default"] {
location_cfg_prepend => $location_cfg_prepend }
}

if $location_cfg_append {
Nginx::Resource::Location["${name}-default"] {
Nginx::Resource::Location["${name_sanitized}-default"] {
location_cfg_append => $location_cfg_append }
}

Expand All @@ -258,7 +259,7 @@
}

if ($listen_port != $ssl_port) {
concat::fragment { "${name}-header":
concat::fragment { "${name_sanitized}-header":
target => $config_file,
content => template('nginx/vhost/vhost_header.erb'),
order => '001',
Expand All @@ -267,7 +268,7 @@

# Create a proper file close stub.
if ($listen_port != $ssl_port) {
concat::fragment { "${name}-footer":
concat::fragment { "${name_sanitized}-footer":
target => $config_file,
content => template('nginx/vhost/vhost_footer.erb'),
order => '699',
Expand All @@ -278,20 +279,20 @@
if ($ssl == true) {
# Access and error logs are named differently in ssl template
$ssl_access_log = $access_log ? {
undef => "${nginx::params::nx_logdir}/ssl-${domain_log_name}.access.log",
undef => "${nginx::params::nx_logdir}/ssl-${name_sanitized}.access.log",
default => $access_log,
}
$ssl_error_log = $error_log ? {
undef => "${nginx::params::nx_logdir}/ssl-${domain_log_name}.error.log",
undef => "${nginx::params::nx_logdir}/ssl-${name_sanitized}.error.log",
default => $error_log,
}

concat::fragment { "${name}-ssl-header":
concat::fragment { "${name_sanitized}-ssl-header":
target => $config_file,
content => template('nginx/vhost/vhost_ssl_header.erb'),
order => '700',
}
concat::fragment { "${name}-ssl-footer":
concat::fragment { "${name_sanitized}-ssl-footer":
target => $config_file,
content => template('nginx/vhost/vhost_ssl_footer.erb'),
order => '999',
Expand All @@ -314,9 +315,9 @@
})
}

file{ "${name}.conf symlink":
file{ "${name_sanitized}.conf symlink":
ensure => $vhost_symlink_ensure,
path => "${vhost_enable_dir}/${name}.conf",
path => "${vhost_enable_dir}/${name_sanitized}.conf",
target => $config_file,
require => Concat[$config_file],
notify => Service['nginx'],
Expand Down

0 comments on commit 69b77d7

Please sign in to comment.