diff --git a/manifests/vhost/proxy.pp b/manifests/vhost/proxy.pp index d0b699c..8f0333b 100644 --- a/manifests/vhost/proxy.pp +++ b/manifests/vhost/proxy.pp @@ -46,7 +46,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, }