Fix proxy and redirect configuration file names.
While working on puppet-lodgeit acceptance tests we found that the configuration file that `httpd::mod::proxy` creates was not being picked up by Apache because it was missing the prefix `.conf`. This transition is required to configure httpd modules correctly on Apache >= 2.4 To prevent Apache from loading two the same configuration twice, we remove the file without extension, so this change does not affect running systems. This change has fixes for `httpd::mod::proxy` and `httpd::mod::redirect` as they have the same issue. We added tests as well to increase the confidence on the fix. The acceptance will be fixed on the follow-up patch, as the redirect grants are broken for 2.4 as well. Change-Id: I82241038d687316f91f18209fe8323c12422e2f8 Co-Authored-By: Danilo Ramalho <dramalho@thoughtworks.com>
This commit is contained in:
parent
edb7660f9b
commit
faf9d932ba
@ -44,7 +44,12 @@ define httpd::vhost::proxy (
|
||||
}
|
||||
|
||||
file { "${priority}-${name}":
|
||||
path => "${httpd::params::vdir}/${priority}-${name}",
|
||||
ensure => absent,
|
||||
path => "${httpd::params::vdir}/${priority}-${name}",
|
||||
}
|
||||
|
||||
file { "${priority}-${name}.conf":
|
||||
path => "${httpd::params::vdir}/${priority}-${name}.conf",
|
||||
content => template($template),
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
|
@ -31,7 +31,12 @@ define httpd::vhost::redirect (
|
||||
$srvname = $name
|
||||
|
||||
file { "${priority}-${name}":
|
||||
path => "${httpd::params::vdir}/${priority}-${name}",
|
||||
ensure => absent,
|
||||
path => "${httpd::params::vdir}/${priority}-${name}",
|
||||
}
|
||||
|
||||
file { "${priority}-${name}.conf":
|
||||
path => "${httpd::params::vdir}/${priority}-${name}.conf",
|
||||
content => template($template),
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
|
@ -112,5 +112,20 @@ describe 'puppet-httpd module' do
|
||||
describe command('a2query -m ssl'), :if => ['debian', 'ubuntu'].include?(os[:family]) do
|
||||
its(:stdout) { should match 'enabled' }
|
||||
end
|
||||
|
||||
describe 'vhosts' do
|
||||
describe command('curl --verbose http://localhost') do
|
||||
its(:stdout) { should include 'Index of /' }
|
||||
end
|
||||
|
||||
describe command('curl --verbose -H "Host: proxy" http://localhost/acceptance.txt') do
|
||||
its(:stdout) { should include 'Acceptance Test' }
|
||||
end
|
||||
|
||||
describe command('curl --verbose -H "Host: redirect" http://localhost') do
|
||||
its(:stdout) { should include '302' }
|
||||
its(:stdout) { should include 'http://localhost:8080/acceptance.txt' }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -10,6 +10,48 @@ httpd::vhost { 'localhost':
|
||||
redirect_ssl => true,
|
||||
}
|
||||
|
||||
# Enable a secondary port to test proxy and redirect modules
|
||||
$override = '
|
||||
Listen 8080
|
||||
<Directory "/html">
|
||||
Options All
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
Allow from all
|
||||
</Directory>
|
||||
'
|
||||
file { "${::httpd::params::vdir}override.conf":
|
||||
content => $override,
|
||||
}
|
||||
file { '/html':
|
||||
ensure => directory,
|
||||
mode => '0755',
|
||||
}
|
||||
file { '/html/acceptance.txt':
|
||||
ensure => present,
|
||||
mode => '0644',
|
||||
content => 'Acceptance Test',
|
||||
require => File['/html'],
|
||||
}
|
||||
httpd::vhost { 'acceptance-server':
|
||||
servername => 'localhost',
|
||||
port => 8080,
|
||||
docroot => '/html',
|
||||
priority => 50,
|
||||
}
|
||||
|
||||
httpd::mod { 'proxy': ensure => present; }
|
||||
httpd::mod { 'proxy_http': ensure => present; }
|
||||
httpd::vhost::proxy { 'proxy':
|
||||
port => 80,
|
||||
dest => 'http://localhost:8080',
|
||||
}
|
||||
|
||||
httpd::vhost::redirect { 'redirect':
|
||||
port => 80,
|
||||
dest => 'http://localhost:8080/acceptance.txt',
|
||||
}
|
||||
|
||||
httpd::mod { 'rewrite':
|
||||
ensure => present,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user