From 003d69f69cdebc5eadcac79890316dc82777e637 Mon Sep 17 00:00:00 2001 From: Mateusz Kowalski Date: Thu, 16 Feb 2017 14:56:07 +0100 Subject: [PATCH] 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 --- manifests/wsgi/apache.pp | 8 ++++---- .../notes/empty-root-url-495e1f1f47372f47.yaml | 3 +++ spec/classes/horizon_wsgi_apache_spec.rb | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/empty-root-url-495e1f1f47372f47.yaml diff --git a/manifests/wsgi/apache.pp b/manifests/wsgi/apache.pp index c2e446ed..c5d6ce0f 100644 --- a/manifests/wsgi/apache.pp +++ b/manifests/wsgi/apache.pp @@ -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 }, })) } diff --git a/releasenotes/notes/empty-root-url-495e1f1f47372f47.yaml b/releasenotes/notes/empty-root-url-495e1f1f47372f47.yaml new file mode 100644 index 00000000..dd23ecb5 --- /dev/null +++ b/releasenotes/notes/empty-root-url-495e1f1f47372f47.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - Fixes wrong apache vhost config when root_url is empty diff --git a/spec/classes/horizon_wsgi_apache_spec.rb b/spec/classes/horizon_wsgi_apache_spec.rb index eb24dce0..d76c0879 100644 --- a/spec/classes/horizon_wsgi_apache_spec.rb +++ b/spec/classes/horizon_wsgi_apache_spec.rb @@ -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