Skip to content

Commit

Permalink
proxypassmatch not supported on sles 10 apache
Browse files Browse the repository at this point in the history
  • Loading branch information
eputnam committed Nov 9, 2016
1 parent 5ed1b42 commit bbc35cc
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 66 deletions.
10 changes: 7 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,13 @@
$lib_path = '/usr/lib64/apache2-prefork'
$suse_lib_path = '/usr/lib64/apache2'
$mpm_module = 'prefork'
$default_ssl_cert = '/etc/ssl/servercerts/servercert.pem'
$default_ssl_key = '/etc/ssl/servercerts/serverkey.pem'
if $::operatingsystemrelease < '11' {
$default_ssl_cert = '/etc/apache2/ssl.crt/snakeoil-rsa.crt'
$default_ssl_key = '/etc/apache2/ssl.key/snakeoil-rsa.key'
} else {
$default_ssl_cert = '/etc/ssl/servercerts/servercert.pem'
$default_ssl_key = '/etc/ssl/servercerts/serverkey.pem'
}
$ssl_certs_dir = '/etc/ssl/certs'
$suphp_addhandler = 'x-httpd-php'
$suphp_engine = 'off'
Expand All @@ -502,7 +507,6 @@
'perl' => 'apache2-mod_perl',
'php5' => 'apache2-mod_php5',
'python' => 'apache2-mod_python',
'security' => 'apache2-mod_security2',
}
} else {
$mod_packages = {
Expand Down
130 changes: 67 additions & 63 deletions spec/acceptance/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,33 @@ class { 'apache': }
end
end

context 'new proxy vhost on port 80' do
it 'should configure an apache proxy vhost' do
pp = <<-EOS
class { 'apache': }
apache::vhost { 'proxy.example.com':
port => '80',
docroot => '/var/www/proxy',
proxy_pass_match => [
{ 'path' => '/foo', 'url' => 'http://backend-foo/'},
],
proxy_preserve_host => true,
proxy_error_override => true,
}
EOS
apply_manifest(pp, :catch_failures => true)
end
unless (fact('operatingsystem') == 'SLES' and fact('operatingsystemmajorrelease') <= '10')
context 'new proxy vhost on port 80' do
it 'should configure an apache proxy vhost' do
pp = <<-EOS
class { 'apache': }
apache::vhost { 'proxy.example.com':
port => '80',
docroot => '#{$docroot}/proxy',
proxy_pass_match => [
{ 'path' => '/foo', 'url' => 'http://backend-foo/'},
],
proxy_preserve_host => true,
proxy_error_override => true,
}
EOS
apply_manifest(pp, :catch_failures => true)
end

describe file("#{$vhost_dir}/25-proxy.example.com.conf") do
it { is_expected.to contain '<VirtualHost \*:80>' }
it { is_expected.to contain "ServerName proxy.example.com" }
it { is_expected.to contain "ProxyPassMatch /foo http://backend-foo/" }
it { is_expected.to contain "ProxyPreserveHost On" }
it { is_expected.to contain "ProxyErrorOverride On" }
it { is_expected.not_to contain "ProxyAddHeaders" }
it { is_expected.not_to contain "<Proxy \*>" }
describe file("#{$vhost_dir}/25-proxy.example.com.conf") do
it { is_expected.to contain '<VirtualHost \*:80>' }
it { is_expected.to contain "ServerName proxy.example.com" }
it { is_expected.to contain "ProxyPassMatch /foo http://backend-foo/" }
it { is_expected.to contain "ProxyPreserveHost On" }
it { is_expected.to contain "ProxyErrorOverride On" }
it { is_expected.not_to contain "ProxyAddHeaders" }
it { is_expected.not_to contain "<Proxy \*>" }
end
end
end

Expand Down Expand Up @@ -664,47 +666,49 @@ class { 'apache': default_vhost => false, }
end
end

context 'proxy_pass_match for alternative vhost' do
it 'should configure a local vhost and a proxy vhost' do
apply_manifest(%{
class { 'apache': default_vhost => false, }
apache::vhost { 'localhost':
docroot => '/var/www/local',
ip => '127.0.0.1',
port => '8888',
}
apache::listen { '*:80': }
apache::vhost { 'proxy.example.com':
docroot => '/var/www',
port => '80',
add_listen => false,
proxy_pass_match => {
'path' => '/',
'url' => 'http://localhost:8888/subdir/',
},
}
host { 'proxy.example.com': ip => '127.0.0.1', }
file { ['/var/www/local', '/var/www/local/subdir']: ensure => directory, }
file { '/var/www/local/subdir/index.html':
ensure => file,
content => "Hello from localhost\\n",
}
}, :catch_failures => true)
end
unless (fact('operatingsystem') == 'SLES' and fact('operatingsystemmajorrelease') <= '10')
context 'proxy_pass_match for alternative vhost' do
it 'should configure a local vhost and a proxy vhost' do
apply_manifest(%{
class { 'apache': default_vhost => false, }
apache::vhost { 'localhost':
docroot => '/var/www/local',
ip => '127.0.0.1',
port => '8888',
}
apache::listen { '*:80': }
apache::vhost { 'proxy.example.com':
docroot => '/var/www',
port => '80',
add_listen => false,
proxy_pass_match => {
'path' => '/',
'url' => 'http://localhost:8888/subdir/',
},
}
host { 'proxy.example.com': ip => '127.0.0.1', }
file { ['/var/www/local', '/var/www/local/subdir']: ensure => directory, }
file { '/var/www/local/subdir/index.html':
ensure => file,
content => "Hello from localhost\\n",
}
}, :catch_failures => true)
end

describe service($service_name) do
if (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8')
pending 'Should be enabled - Bug 760616 on Debian 8'
else
it { should be_enabled }
describe service($service_name) do
if (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '8')
pending 'Should be enabled - Bug 760616 on Debian 8'
else
it { should be_enabled }
end
it { is_expected.to be_running }
end
it { is_expected.to be_running }
end

it 'should get a response from the back end' do
shell("/usr/bin/curl --max-redirs 0 proxy.example.com:80") do |r|
expect(r.stdout).to eq("Hello from localhost\n")
expect(r.exit_code).to eq(0)
it 'should get a response from the back end' do
shell("/usr/bin/curl --max-redirs 0 proxy.example.com:80") do |r|
expect(r.stdout).to eq("Hello from localhost\n")
expect(r.exit_code).to eq(0)
end
end
end
end
Expand Down Expand Up @@ -1348,7 +1352,7 @@ class { 'apache::mod::wsgi': }
end
end

context 'on everything but lucid', :unless => (fact('lsbdistcodename') == 'lucid' or (fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') < '12')) do
context 'on everything but lucid', :unless => (fact('lsbdistcodename') == 'lucid' or fact('operatingsystem') == 'SLES') do
it 'import_script applies cleanly' do
pp = <<-EOS
class { 'apache': }
Expand Down

0 comments on commit bbc35cc

Please sign in to comment.