Merge pull request #209 from abraham1901/dev
Bugfix: Fixed long names virtual hosts
This commit is contained in:
commit
69b77d710a
1 changed files with 17 additions and 16 deletions
|
@ -159,7 +159,9 @@ define nginx::resource::vhost (
|
||||||
'absent' => absent,
|
'absent' => absent,
|
||||||
default => 'link',
|
default => 'link',
|
||||||
}
|
}
|
||||||
$config_file = "${vhost_dir}/${name}.conf"
|
|
||||||
|
$name_sanitized = regsubst($name, ' ', '_', 'G')
|
||||||
|
$config_file = "${vhost_dir}/${name_sanitized}.conf"
|
||||||
|
|
||||||
File {
|
File {
|
||||||
ensure => $ensure ? {
|
ensure => $ensure ? {
|
||||||
|
@ -188,13 +190,12 @@ define nginx::resource::vhost (
|
||||||
# This was a lot to add up in parameter list so add it down here
|
# 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
|
# Also opted to add more logic here and keep template cleaner which
|
||||||
# unfortunately means resorting to the $varname_real thing
|
# unfortunately means resorting to the $varname_real thing
|
||||||
$domain_log_name = regsubst($name, ' ', '_', 'G')
|
|
||||||
$access_log_real = $access_log ? {
|
$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,
|
default => $access_log,
|
||||||
}
|
}
|
||||||
$error_log_real = $error_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,
|
default => $error_log,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,9 +212,9 @@ define nginx::resource::vhost (
|
||||||
|
|
||||||
if $use_default_location == true {
|
if $use_default_location == true {
|
||||||
# Create the default location reference for the vHost
|
# Create the default location reference for the vHost
|
||||||
nginx::resource::location {"${name}-default":
|
nginx::resource::location {"${name_sanitized}-default":
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
vhost => $name,
|
vhost => $name_sanitized,
|
||||||
ssl => $ssl,
|
ssl => $ssl,
|
||||||
ssl_only => $ssl_only,
|
ssl_only => $ssl_only,
|
||||||
location => '/',
|
location => '/',
|
||||||
|
@ -240,12 +241,12 @@ define nginx::resource::vhost (
|
||||||
|
|
||||||
# Support location_cfg_prepend and location_cfg_append on default location created by vhost
|
# Support location_cfg_prepend and location_cfg_append on default location created by vhost
|
||||||
if $location_cfg_prepend {
|
if $location_cfg_prepend {
|
||||||
Nginx::Resource::Location["${name}-default"] {
|
Nginx::Resource::Location["${name_sanitized}-default"] {
|
||||||
location_cfg_prepend => $location_cfg_prepend }
|
location_cfg_prepend => $location_cfg_prepend }
|
||||||
}
|
}
|
||||||
|
|
||||||
if $location_cfg_append {
|
if $location_cfg_append {
|
||||||
Nginx::Resource::Location["${name}-default"] {
|
Nginx::Resource::Location["${name_sanitized}-default"] {
|
||||||
location_cfg_append => $location_cfg_append }
|
location_cfg_append => $location_cfg_append }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +259,7 @@ define nginx::resource::vhost (
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($listen_port != $ssl_port) {
|
if ($listen_port != $ssl_port) {
|
||||||
concat::fragment { "${name}-header":
|
concat::fragment { "${name_sanitized}-header":
|
||||||
target => $config_file,
|
target => $config_file,
|
||||||
content => template('nginx/vhost/vhost_header.erb'),
|
content => template('nginx/vhost/vhost_header.erb'),
|
||||||
order => '001',
|
order => '001',
|
||||||
|
@ -267,7 +268,7 @@ define nginx::resource::vhost (
|
||||||
|
|
||||||
# Create a proper file close stub.
|
# Create a proper file close stub.
|
||||||
if ($listen_port != $ssl_port) {
|
if ($listen_port != $ssl_port) {
|
||||||
concat::fragment { "${name}-footer":
|
concat::fragment { "${name_sanitized}-footer":
|
||||||
target => $config_file,
|
target => $config_file,
|
||||||
content => template('nginx/vhost/vhost_footer.erb'),
|
content => template('nginx/vhost/vhost_footer.erb'),
|
||||||
order => '699',
|
order => '699',
|
||||||
|
@ -278,20 +279,20 @@ define nginx::resource::vhost (
|
||||||
if ($ssl == true) {
|
if ($ssl == true) {
|
||||||
# Access and error logs are named differently in ssl template
|
# Access and error logs are named differently in ssl template
|
||||||
$ssl_access_log = $access_log ? {
|
$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,
|
default => $access_log,
|
||||||
}
|
}
|
||||||
$ssl_error_log = $error_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,
|
default => $error_log,
|
||||||
}
|
}
|
||||||
|
|
||||||
concat::fragment { "${name}-ssl-header":
|
concat::fragment { "${name_sanitized}-ssl-header":
|
||||||
target => $config_file,
|
target => $config_file,
|
||||||
content => template('nginx/vhost/vhost_ssl_header.erb'),
|
content => template('nginx/vhost/vhost_ssl_header.erb'),
|
||||||
order => '700',
|
order => '700',
|
||||||
}
|
}
|
||||||
concat::fragment { "${name}-ssl-footer":
|
concat::fragment { "${name_sanitized}-ssl-footer":
|
||||||
target => $config_file,
|
target => $config_file,
|
||||||
content => template('nginx/vhost/vhost_ssl_footer.erb'),
|
content => template('nginx/vhost/vhost_ssl_footer.erb'),
|
||||||
order => '999',
|
order => '999',
|
||||||
|
@ -314,9 +315,9 @@ define nginx::resource::vhost (
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
file{ "${name}.conf symlink":
|
file{ "${name_sanitized}.conf symlink":
|
||||||
ensure => $vhost_symlink_ensure,
|
ensure => $vhost_symlink_ensure,
|
||||||
path => "${vhost_enable_dir}/${name}.conf",
|
path => "${vhost_enable_dir}/${name_sanitized}.conf",
|
||||||
target => $config_file,
|
target => $config_file,
|
||||||
require => Concat[$config_file],
|
require => Concat[$config_file],
|
||||||
notify => Service['nginx'],
|
notify => Service['nginx'],
|
||||||
|
|
Loading…
Reference in a new issue