From faf9d932ba96ff22c5826e4b7a4dba46c6f6fd4f Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Fri, 18 Sep 2015 17:27:57 -0300 Subject: [PATCH] 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 --- manifests/vhost/proxy.pp | 7 ++++- manifests/vhost/redirect.pp | 7 ++++- spec/acceptance/basic_spec.rb | 15 +++++++++++ spec/acceptance/fixtures/default.pp | 42 +++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/manifests/vhost/proxy.pp b/manifests/vhost/proxy.pp index 72d091d..1126c7e 100644 --- a/manifests/vhost/proxy.pp +++ b/manifests/vhost/proxy.pp @@ -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', diff --git a/manifests/vhost/redirect.pp b/manifests/vhost/redirect.pp index 589ba6d..71eebbb 100644 --- a/manifests/vhost/redirect.pp +++ b/manifests/vhost/redirect.pp @@ -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', diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb index 05a4176..12d55ae 100644 --- a/spec/acceptance/basic_spec.rb +++ b/spec/acceptance/basic_spec.rb @@ -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 diff --git a/spec/acceptance/fixtures/default.pp b/spec/acceptance/fixtures/default.pp index 9b3b7ec..ebd192d 100644 --- a/spec/acceptance/fixtures/default.pp +++ b/spec/acceptance/fixtures/default.pp @@ -10,6 +10,48 @@ httpd::vhost { 'localhost': redirect_ssl => true, } +# Enable a secondary port to test proxy and redirect modules +$override = ' +Listen 8080 + + Options All + AllowOverride All + Require all granted + Allow from all + +' +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, }