Avoid causing redirect loop

If root_url is '/' it's incorrect, unecessary to redirect from '^/$' to
'/'. It also causes a redirect loop.

This change introduces two sets of checks to avoid configuring apache::vhost
with redirectmatch_regexp and redirectmatch_dest if root_url is '/'.

Change-Id: Id5dcad250e3909e4e1431d9afd5460aa40a4c318
Closes-Bug: #1551759
Signed-off-by: Martin Millnert <martin@millnert.se>
This commit is contained in:
Martin Millnert 2016-03-01 16:02:58 +01:00 committed by Alex Schultz
parent be6f352eb2
commit 000a40263b
2 changed files with 23 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 => $redirect_match,
redirectmatch_dest => $redirect_url,
redirectmatch_regexp => $root_url ? { '/' => undef, default => $redirect_match },
redirectmatch_dest => $root_url ? { '/' => 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 => '^/$',
redirectmatch_dest => $root_url,
redirectmatch_regexp => $root_url ? { '/' => undef, default => '^/$' },
redirectmatch_dest => $root_url ? { '/' => undef, default => $root_url },
}))
}

View File

@ -176,6 +176,25 @@ describe 'horizon::wsgi::apache' do
end
context 'with root_url set to /' 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