Update directory structure & allow to configure paths (tmp, log, cache)

This commit is contained in:
Nicolas Le Goff
2014-09-05 11:28:25 +02:00
parent 69fd50906f
commit de7988689e
2201 changed files with 850 additions and 13650 deletions

View File

@@ -0,0 +1,6 @@
include apache
include apache::mod::php
include apache::mod::cgi
include apache::mod::userdir
include apache::mod::disk_cache
include apache::mod::proxy_http

View File

@@ -0,0 +1 @@
include apache::dev

View File

@@ -0,0 +1 @@
include apache

View File

@@ -0,0 +1,11 @@
# Tests the path and identifier parameters for the apache::mod class
# Base class for clarity:
class { 'apache': }
# Exaple parameter usage:
apache::mod { 'testmod':
path => '/usr/some/path/mod_testmod.so',
id => 'testmod_custom_name',
}

View File

@@ -0,0 +1,9 @@
## Default mods
# Base class. Declares default vhost on port 80 and default ssl
# vhost on port 443 listening on all interfaces and serving
# $apache::docroot, and declaring our default set of modules.
class { 'apache':
default_mods => true,
}

View File

@@ -0,0 +1,16 @@
## custom mods
# Base class. Declares default vhost on port 80 and default ssl
# vhost on port 443 listening on all interfaces and serving
# $apache::docroot, and declaring a custom set of modules.
class { 'apache':
default_mods => [
'info',
'alias',
'mime',
'env',
'setenv',
'expires',
],
}

View File

@@ -0,0 +1,4 @@
class { 'apache':
mpm_module => 'prefork',
}
include apache::mod::php

View File

@@ -0,0 +1,238 @@
## Default vhosts, and custom vhosts
# NB: Please see the other vhost_*.pp example files for further
# examples.
# Base class. Declares default vhost on port 80 and default ssl
# vhost on port 443 listening on all interfaces and serving
# $apache::docroot
class { 'apache': }
# Most basic vhost
apache::vhost { 'first.example.com':
port => '80',
docroot => '/var/www/first',
}
# Vhost with different docroot owner/group/mode
apache::vhost { 'second.example.com':
port => '80',
docroot => '/var/www/second',
docroot_owner => 'third',
docroot_group => 'third',
docroot_mode => '0770',
}
# Vhost with serveradmin
apache::vhost { 'third.example.com':
port => '80',
docroot => '/var/www/third',
serveradmin => 'admin@example.com',
}
# Vhost with ssl (uses default ssl certs)
apache::vhost { 'ssl.example.com':
port => '443',
docroot => '/var/www/ssl',
ssl => true,
}
# Vhost with ssl and specific ssl certs
apache::vhost { 'fourth.example.com':
port => '443',
docroot => '/var/www/fourth',
ssl => true,
ssl_cert => '/etc/ssl/fourth.example.com.cert',
ssl_key => '/etc/ssl/fourth.example.com.key',
}
# Vhost with english title and servername parameter
apache::vhost { 'The fifth vhost':
servername => 'fifth.example.com',
port => '80',
docroot => '/var/www/fifth',
}
# Vhost with server aliases
apache::vhost { 'sixth.example.com':
serveraliases => [
'sixth.example.org',
'sixth.example.net',
],
port => '80',
docroot => '/var/www/fifth',
}
# Vhost with alternate options
apache::vhost { 'seventh.example.com':
port => '80',
docroot => '/var/www/seventh',
options => [
'Indexes',
'MultiViews',
],
}
# Vhost with AllowOverride for .htaccess
apache::vhost { 'eighth.example.com':
port => '80',
docroot => '/var/www/eighth',
override => 'All',
}
# Vhost with access and error logs disabled
apache::vhost { 'ninth.example.com':
port => '80',
docroot => '/var/www/ninth',
access_log => false,
error_log => false,
}
# Vhost with custom access and error logs and logroot
apache::vhost { 'tenth.example.com':
port => '80',
docroot => '/var/www/tenth',
access_log_file => 'tenth_vhost.log',
error_log_file => 'tenth_vhost_error.log',
logroot => '/var/log',
}
# Vhost with a cgi-bin
apache::vhost { 'eleventh.example.com':
port => '80',
docroot => '/var/www/eleventh',
scriptalias => '/usr/lib/cgi-bin',
}
# Vhost with a proxypass configuration
apache::vhost { 'twelfth.example.com':
port => '80',
docroot => '/var/www/twelfth',
proxy_dest => 'http://internal.example.com:8080/twelfth',
no_proxy_uris => ['/login','/logout'],
}
# Vhost to redirect /login and /logout
apache::vhost { 'thirteenth.example.com':
port => '80',
docroot => '/var/www/thirteenth',
redirect_source => [
'/login',
'/logout',
],
redirect_dest => [
'http://10.0.0.10/login',
'http://10.0.0.10/logout',
],
}
# Vhost to permamently redirect
apache::vhost { 'fourteenth.example.com':
port => '80',
docroot => '/var/www/fourteenth',
redirect_source => '/blog',
redirect_dest => 'http://blog.example.com',
redirect_status => 'permanent',
}
# Vhost with a rack configuration
apache::vhost { 'fifteenth.example.com':
port => '80',
docroot => '/var/www/fifteenth',
rack_base_uris => ['/rackapp1', '/rackapp2'],
}
# Vhost to redirect non-ssl to ssl
apache::vhost { 'sixteenth.example.com non-ssl':
servername => 'sixteenth.example.com',
port => '80',
docroot => '/var/www/sixteenth',
rewrites => [
{
comment => 'redirect non-SSL traffic to SSL site',
rewrite_cond => ['%{HTTPS} off'],
rewrite_rule => ['(.*) https://%{HTTPS_HOST}%{REQUEST_URI}'],
}
]
}
apache::vhost { 'sixteenth.example.com ssl':
servername => 'sixteenth.example.com',
port => '443',
docroot => '/var/www/sixteenth',
ssl => true,
}
# Vhost to redirect non-ssl to ssl using old rewrite method
apache::vhost { 'sixteenth.example.com non-ssl old rewrite':
servername => 'sixteenth.example.com',
port => '80',
docroot => '/var/www/sixteenth',
rewrite_cond => '%{HTTPS} off',
rewrite_rule => '(.*) https://%{HTTPS_HOST}%{REQUEST_URI}',
}
apache::vhost { 'sixteenth.example.com ssl old rewrite':
servername => 'sixteenth.example.com',
port => '443',
docroot => '/var/www/sixteenth',
ssl => true,
}
# Vhost to block repository files
apache::vhost { 'seventeenth.example.com':
port => '80',
docroot => '/var/www/seventeenth',
block => 'scm',
}
# Vhost with special environment variables
apache::vhost { 'eighteenth.example.com':
port => '80',
docroot => '/var/www/eighteenth',
setenv => ['SPECIAL_PATH /foo/bin','KILROY was_here'],
}
apache::vhost { 'nineteenth.example.com':
port => '80',
docroot => '/var/www/nineteenth',
setenvif => 'Host "^([^\.]*)\.website\.com$" CLIENT_NAME=$1',
}
# Vhost with additional include files
apache::vhost { 'twentyieth.example.com':
port => '80',
docroot => '/var/www/twelfth',
additional_includes => ['/tmp/proxy_group_a','/tmp/proxy_group_b'],
}
# Vhost with alias for subdomain mapped to same named directory
# http://example.com.loc => /var/www/example.com
apache::vhost { 'subdomain.loc':
vhost_name => '*',
port => '80',
virtual_docroot => '/var/www/%-2+',
docroot => '/var/www',
serveraliases => ['*.loc',],
}
# Vhost with SSLProtocol,SSLCipherSuite, SSLHonorCipherOrder
apache::vhost { 'securedomain.com':
priority => '10',
vhost_name => 'www.securedomain.com',
port => '443',
docroot => '/var/www/secure',
ssl => true,
ssl_cert => '/etc/ssl/securedomain.cert',
ssl_key => '/etc/ssl/securedomain.key',
ssl_chain => '/etc/ssl/securedomain.crt',
ssl_protocol => '-ALL +SSLv3 +TLSv1',
ssl_cipher => 'ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM',
ssl_honorcipherorder => 'On',
add_listen => false,
}
# Vhost with access log environment variables writing control
apache::vhost { 'twentyfirst.example.com':
port => '80',
docroot => '/var/www/twentyfirst',
access_log_env_var => 'admin',
}

View File

@@ -0,0 +1,44 @@
# Base class. Declares default vhost on port 80 and default ssl
# vhost on port 443 listening on all interfaces and serving
# $apache::docroot
class { 'apache': }
# Example from README adapted.
apache::vhost { 'readme.example.net':
docroot => '/var/www/readme',
directories => [
{
'path' => '/var/www/readme',
'ServerTokens' => 'prod' ,
},
{
'path' => '/usr/share/empty',
'allow' => 'from all',
},
],
}
# location test
apache::vhost { 'location.example.net':
docroot => '/var/www/location',
directories => [
{
'path' => '/location',
'provider' => 'location',
'ServerTokens' => 'prod'
},
],
}
# files test, curedly disable access to accidental backup files.
apache::vhost { 'files.example.net':
docroot => '/var/www/files',
directories => [
{
'path' => '(\.swp|\.bak|~)$',
'provider' => 'filesmatch',
'deny' => 'from all'
},
],
}

View File

@@ -0,0 +1,25 @@
## IP-based vhosts on any listen port
# IP-based vhosts respond to requests on specific IP addresses.
# Base class. Turn off the default vhosts; we will be declaring
# all vhosts below.
class { 'apache':
default_vhost => false,
}
# Listen on port 80 and 81; required because the following vhosts
# are not declared with a port parameter.
apache::listen { '80': }
apache::listen { '81': }
# IP-based vhosts
apache::vhost { 'first.example.com':
ip => '10.0.0.10',
docroot => '/var/www/first',
ip_based => true,
}
apache::vhost { 'second.example.com':
ip => '10.0.0.11',
docroot => '/var/www/second',
ip_based => true,
}

View File

@@ -0,0 +1,23 @@
## SSL-enabled vhosts
# SSL-enabled vhosts respond only to HTTPS queries.
# Base class. Turn off the default vhosts; we will be declaring
# all vhosts below.
class { 'apache':
default_vhost => false,
}
# Non-ssl vhost
apache::vhost { 'first.example.com non-ssl':
servername => 'first.example.com',
port => '80',
docroot => '/var/www/first',
}
# SSL vhost at the same domain
apache::vhost { 'first.example.com ssl':
servername => 'first.example.com',
port => '443',
docroot => '/var/www/first',
ssl => true,
}

View File

@@ -0,0 +1,53 @@
## Declare ip-based and name-based vhosts
# Mixing Name-based vhost with IP-specific vhosts requires `add_listen =>
# 'false'` on the non-IP vhosts
# Base class. Turn off the default vhosts; we will be declaring
# all vhosts below.
class { 'apache':
default_vhost => false,
}
# Add two an IP-based vhost on 10.0.0.10, ssl and non-ssl
apache::vhost { 'The first IP-based vhost, non-ssl':
servername => 'first.example.com',
ip => '10.0.0.10',
port => '80',
ip_based => true,
docroot => '/var/www/first',
}
apache::vhost { 'The first IP-based vhost, ssl':
servername => 'first.example.com',
ip => '10.0.0.10',
port => '443',
ip_based => true,
docroot => '/var/www/first-ssl',
ssl => true,
}
# Two name-based vhost listening on 10.0.0.20
apache::vhost { 'second.example.com':
ip => '10.0.0.20',
port => '80',
docroot => '/var/www/second',
}
apache::vhost { 'third.example.com':
ip => '10.0.0.20',
port => '80',
docroot => '/var/www/third',
}
# Two name-based vhosts without IPs specified, so that they will answer on either 10.0.0.10 or 10.0.0.20 . It is requried to declare
# `add_listen => 'false'` to disable declaring "Listen 80" which will conflict
# with the IP-based preceeding vhosts.
apache::vhost { 'fourth.example.com':
port => '80',
docroot => '/var/www/fourth',
add_listen => false,
}
apache::vhost { 'fifth.example.com':
port => '80',
docroot => '/var/www/fifth',
add_listen => false,
}