Puppet Class: profile::mediawiki::httpd
- Defined in:
- modules/profile/manifests/mediawiki/httpd.pp
Overview
Class profile::mediawiki::httpd
Installs and configures a web environment for mediawiki
Only things not installed here:
-
Any specific website
-
Any special listening port
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'modules/profile/manifests/mediawiki/httpd.pp', line 8
class profile::mediawiki::httpd(
Integer $logrotate_retention = lookup('profile::mediawiki::httpd::logrotate_retention', {'default_value' => 30}),
Optional[Integer] $workers_limit = lookup('profile::mediawiki::httpd::workers_limit', {'default_value' => undef}),
String $cluster = lookup('cluster'),
Optional[Boolean] $enable_forensic_log = lookup('profile::mediawiki::httpd::enable_forensic_log', {'default_value' => false}),
) {
tag 'mediawiki', 'mw-apache-config'
class { '::httpd':
period => 'daily',
rotate => $logrotate_retention,
enable_forensic_log => $enable_forensic_log,
modules => [
'alias',
'authz_host',
'autoindex',
'dir',
'expires',
'headers',
'mime',
'rewrite',
'setenvif',
'proxy_fcgi',
]
}
systemd::unit{ 'apache2':
content => "[Service]\nCPUAccounting=yes\n",
override => true,
}
# Modules we don't enable.
# Note that deflate and filter are activated deep down in the
# apache sites, we should probably move them here
::httpd::mod_conf { [
'auth_basic',
'authn_file',
'authz_default',
'authz_groupfile',
'authz_user',
'cgi',
'deflate',
'env',
'negotiation',
'reqtimeout',
]:
ensure => absent,
}
file { '/etc/apache2/mods-available/expires.conf':
ensure => present,
source => 'puppet:///modules/mediawiki/apache/modules/expires.conf',
owner => 'root',
group => 'root',
mode => '0444',
notify => Service['apache2'],
require => Package['apache2'],
}
file { '/etc/apache2/mods-available/autoindex.conf':
ensure => present,
source => 'puppet:///modules/mediawiki/apache/modules/autoindex.conf',
owner => 'root',
group => 'root',
mode => '0444',
notify => Service['apache2'],
require => Package['apache2'],
}
file { '/etc/apache2/mods-available/setenvif.conf':
ensure => present,
source => 'puppet:///modules/mediawiki/apache/modules/setenvif.conf',
owner => 'root',
group => 'root',
mode => '0444',
notify => Service['apache2'],
require => Package['apache2'],
}
file { '/etc/apache2/mods-available/mime.conf':
ensure => present,
source => 'puppet:///modules/mediawiki/apache/modules/mime.conf',
owner => 'root',
group => 'root',
mode => '0444',
notify => Service['apache2'],
require => Package['apache2'],
}
# Add headers lost by mod_proxy_fastcgi
::httpd::conf { 'fcgi_headers':
source => 'puppet:///modules/mediawiki/apache/configs/fcgi_headers.conf',
priority => 0,
}
# MPM configuration
$threads_per_child = 25
$apache_server_limit = $::processorcount
$max_workers = $threads_per_child * $apache_server_limit
if $workers_limit and is_integer($workers_limit) {
$max_req_workers = min($workers_limit, $max_workers)
}
else {
# Default if no override has been defined
$max_req_workers = $max_workers
}
# TODO: move this to the httpd::mpm configuration once we can
::httpd::conf { 'worker':
content => template('mediawiki/apache/worker.conf.erb')
}
class { '::httpd::mpm':
mpm => 'worker'
}
file { '/etc/apache2/apache2.conf':
content => template('mediawiki/apache/apache2.conf.erb'),
owner => 'root',
group => 'root',
mode => '0444',
before => Service['apache2'],
require => Package['apache2'],
}
file { '/var/lock/apache2':
ensure => directory,
owner => $::mediawiki::users::web,
group => 'root',
mode => '0755',
before => File['/etc/apache2/apache2.conf'],
}
::httpd::env { 'chuid_apache':
vars => {
'APACHE_RUN_USER' => $::mediawiki::users::web,
'APACHE_RUN_GROUP' => $::mediawiki::users::web,
},
before => Service['apache2'],
require => Package['apache2'],
}
# Add the APACHE_RUN_PORT variable to the environment
::httpd::env { 'apache_run_port':
vars => {
'APACHE_RUN_PORT' => '80',
},
before => Service['apache2'],
require => Package['apache2'],
}
# Set the Server response header to be equal to the app server FQDN.
package { 'libapache2-mod-security2':
ensure => present
}
::httpd::mod_conf { 'security2':
}
::httpd::conf { 'server_header':
content => template('mediawiki/apache/server-header.conf.erb'),
}
# Expose a SERVERGROUP variable to php-fpm
::httpd::conf { 'wikimedia_cluster':
content => "SetEnvIf Request_URI \".\" SERVERGROUP=${cluster}\n"
}
# Starting with Debian 9 libapache2-mod-security2 includes the following
# in /etc/apache2/mods-enabled/security2.conf:
# # Include OWASP ModSecurity CRS rules if installed
# IncludeOptional /usr/share/modsecurity-crs/owasp-crs*.load
# The directory /usr/share/modsecurity-crs is shipped by the
# modsecurity-crs package, but it's only a Recommends: of
# libapache2-mod-security2, so it doesn'get installed. And IncludeOptional
# is only optional for the full path, so if /usr/share/modsecurity-crs doesn't
# exist, it bails out and apache refuses to start/restart. As such, ship an
# empty directory to make that include truly optional
# In addition IncludeOptional expects a wildcard (which the original config
# from modsecurity-crs doesn't ship, so we also need to ship an empty
# stub config
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=878920
# https://bz.apache.org/bugzilla/show_bug.cgi?id=57585
# Once we're running a version of the patch proposed in Apache bugzilla, this
# workaround can be removed
file { '/usr/share/modsecurity-crs':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0775',
before => File['/usr/share/modsecurity-crs/owasp-crs.load'],
}
file { '/usr/share/modsecurity-crs/owasp-crs.load':
owner => 'root',
content => '',
group => 'root',
mode => '0444',
before => Service['apache2'],
}
}
|