Avoid empty redirect rule in vhost config

When root_url is empty, an incorrect rewrite rule will be
created at vhosts config file causing httpd failure.
In order not to create any rule when root_url is empty,
the value should be ignored inside redirectmatch parameter

Change-Id: Idd4ac6a271b4c8d8e53ab27c68abd821a3aa0249
Closes-bug: #1665380
This commit is contained in:
Mateusz Kowalski 2017-02-16 14:56:07 +01:00
parent 7545989c46
commit 003d69f69c
3 changed files with 25 additions and 4 deletions

View File

@ -236,8 +236,8 @@ class horizon::wsgi::apache (
}
ensure_resource('apache::vhost', $vhost_conf_name, merge ($default_vhost_conf, $extra_params, {
redirectmatch_regexp => $root_url ? { '/' => undef, default => $redirect_match },
redirectmatch_dest => $root_url ? { '/' => undef, default => $redirect_url },
redirectmatch_regexp => $root_url ? { '' => undef, '/' => undef, default => $redirect_match },
redirectmatch_dest => $root_url ? { '' => undef, '/' => undef, default => $redirect_url },
}))
ensure_resource('apache::vhost', $vhost_ssl_conf_name, merge ($default_vhost_conf, $extra_params, {
access_log_file => 'horizon_ssl_access.log',
@ -248,8 +248,8 @@ class horizon::wsgi::apache (
ensure => $ensure_ssl_vhost,
wsgi_daemon_process => 'horizon-ssl',
wsgi_process_group => 'horizon-ssl',
redirectmatch_regexp => $root_url ? { '/' => undef, default => '^/$' },
redirectmatch_dest => $root_url ? { '/' => undef, default => $root_url },
redirectmatch_regexp => $root_url ? { '' => undef, '/' => undef, default => '^/$' },
redirectmatch_dest => $root_url ? { '' => undef, '/' => undef, default => $root_url },
}))
}

View File

@ -0,0 +1,3 @@
---
fixes:
- Fixes wrong apache vhost config when root_url is empty

View File

@ -195,6 +195,24 @@ describe 'horizon::wsgi::apache' do
end
end
context 'with root_url set to empty' do
before do
params.merge!({
:root_url => '',
})
end
it 'should not configure redirectmatch' do
is_expected.to_not contain_apache__vhost('horizon_vhost').with(
'redirectmatch_regexp' => '(.*)',
'redirectmatch_dest' => '/'
)
is_expected.to_not contain_apache__vhost('horizon_ssl_vhost').with(
'redirectmatch_regexp' => '^/$',
'redirectmatch_dest' => ''
)
end
end
end
end