2014-11-05 15:32:09 +01:00
|
|
|
<?php
|
2016-02-08 15:41:00 +01:00
|
|
|
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
2014-11-05 15:32:09 +01:00
|
|
|
|
2014-11-13 12:50:55 +01:00
|
|
|
namespace Icinga\Module\Setup\Webserver;
|
|
|
|
|
|
|
|
use Icinga\Module\Setup\Webserver;
|
2014-11-05 15:32:09 +01:00
|
|
|
|
|
|
|
/**
|
2014-11-13 12:50:55 +01:00
|
|
|
* Generate Apache 2.x configuration
|
2014-11-05 15:32:09 +01:00
|
|
|
*/
|
2014-11-13 12:50:55 +01:00
|
|
|
class Apache extends Webserver
|
2014-11-05 15:32:09 +01:00
|
|
|
{
|
2018-02-12 00:04:19 +01:00
|
|
|
protected $fpmUri = 'fcgi://127.0.0.1:9000';
|
2018-12-21 15:29:06 +01:00
|
|
|
protected $enableFpm = false;
|
2018-01-18 08:54:35 +01:00
|
|
|
|
2014-11-05 15:32:09 +01:00
|
|
|
protected function getTemplate()
|
|
|
|
{
|
2018-12-21 15:29:06 +01:00
|
|
|
if (! $this->enableFpm) {
|
2014-11-07 09:18:16 +01:00
|
|
|
return <<<'EOD'
|
2014-11-13 14:18:14 +01:00
|
|
|
Alias {urlPath} "{documentRoot}"
|
2014-11-07 10:34:53 +01:00
|
|
|
|
2017-11-29 14:31:47 +01:00
|
|
|
# Remove comments if you want to use PHP FPM and your Apache version is older than 2.4
|
|
|
|
#<IfVersion < 2.4>
|
|
|
|
# # Forward PHP requests to FPM
|
2017-12-04 14:16:34 +01:00
|
|
|
# SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
2017-11-29 14:31:47 +01:00
|
|
|
# <LocationMatch "^{urlPath}/(.*\.php)$">
|
2018-12-21 15:29:06 +01:00
|
|
|
# ProxyPassMatch "fcgi://{fpmUri}/{documentRoot}/$1"
|
2017-11-29 14:31:47 +01:00
|
|
|
# </LocationMatch>
|
|
|
|
#</IfVersion>
|
|
|
|
|
2014-11-13 13:16:49 +01:00
|
|
|
<Directory "{documentRoot}">
|
2014-11-07 10:34:53 +01:00
|
|
|
Options SymLinksIfOwnerMatch
|
|
|
|
AllowOverride None
|
|
|
|
|
2017-11-16 11:06:09 +01:00
|
|
|
DirectoryIndex index.php
|
|
|
|
|
2014-11-07 10:34:53 +01:00
|
|
|
<IfModule mod_authz_core.c>
|
|
|
|
# Apache 2.4
|
|
|
|
<RequireAll>
|
|
|
|
Require all granted
|
|
|
|
</RequireAll>
|
|
|
|
</IfModule>
|
|
|
|
|
|
|
|
<IfModule !mod_authz_core.c>
|
|
|
|
# Apache 2.2
|
|
|
|
Order allow,deny
|
|
|
|
Allow from all
|
|
|
|
</IfModule>
|
|
|
|
|
2014-11-13 14:05:13 +01:00
|
|
|
SetEnv ICINGAWEB_CONFIGDIR "{configDir}"
|
2014-11-07 10:34:53 +01:00
|
|
|
|
|
|
|
EnableSendfile Off
|
|
|
|
|
2014-11-11 22:02:40 +01:00
|
|
|
<IfModule mod_rewrite.c>
|
|
|
|
RewriteEngine on
|
2014-11-13 14:18:14 +01:00
|
|
|
RewriteBase {urlPath}/
|
2014-11-11 22:02:40 +01:00
|
|
|
RewriteCond %{REQUEST_FILENAME} -s [OR]
|
|
|
|
RewriteCond %{REQUEST_FILENAME} -l [OR]
|
|
|
|
RewriteCond %{REQUEST_FILENAME} -d
|
|
|
|
RewriteRule ^.*$ - [NC,L]
|
|
|
|
RewriteRule ^.*$ index.php [NC,L]
|
|
|
|
</IfModule>
|
|
|
|
|
|
|
|
<IfModule !mod_rewrite.c>
|
|
|
|
DirectoryIndex error_norewrite.html
|
2017-11-17 11:41:04 +01:00
|
|
|
ErrorDocument 404 {urlPath}/error_norewrite.html
|
2014-11-11 22:02:40 +01:00
|
|
|
</IfModule>
|
2017-11-29 14:31:47 +01:00
|
|
|
|
2017-12-04 14:14:34 +01:00
|
|
|
# Remove comments if you want to use PHP FPM and your Apache version
|
|
|
|
# is greater than or equal to 2.4
|
2017-11-29 14:31:47 +01:00
|
|
|
# <IfVersion >= 2.4>
|
|
|
|
# # Forward PHP requests to FPM
|
2017-12-04 14:16:34 +01:00
|
|
|
# SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
2017-11-29 14:31:47 +01:00
|
|
|
# <FilesMatch "\.php$">
|
2018-01-18 08:54:35 +01:00
|
|
|
# SetHandler "proxy:{fpmUri}"
|
2017-11-29 14:31:47 +01:00
|
|
|
# ErrorDocument 503 {urlPath}/error_unavailable.html
|
|
|
|
# </FilesMatch>
|
|
|
|
# </IfVersion>
|
2014-11-07 10:34:53 +01:00
|
|
|
</Directory>
|
2014-11-07 09:18:16 +01:00
|
|
|
EOD;
|
2018-12-21 15:29:06 +01:00
|
|
|
} else {
|
|
|
|
return <<<'EOD'
|
|
|
|
Alias {urlPath} "{documentRoot}"
|
|
|
|
|
|
|
|
<IfVersion < 2.4>
|
|
|
|
# Forward PHP requests to FPM
|
|
|
|
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
|
|
|
<LocationMatch "^{urlPath}/(.*\.php)$">
|
|
|
|
ProxyPassMatch "fcgi://{fpmUri}/{documentRoot}/$1"
|
|
|
|
</LocationMatch>
|
|
|
|
</IfVersion>
|
|
|
|
|
|
|
|
<Directory "{documentRoot}">
|
|
|
|
Options SymLinksIfOwnerMatch
|
|
|
|
AllowOverride None
|
|
|
|
|
|
|
|
DirectoryIndex index.php
|
|
|
|
|
|
|
|
<IfModule mod_authz_core.c>
|
|
|
|
# Apache 2.4
|
|
|
|
<RequireAll>
|
|
|
|
Require all granted
|
|
|
|
</RequireAll>
|
|
|
|
</IfModule>
|
|
|
|
|
|
|
|
<IfModule !mod_authz_core.c>
|
|
|
|
# Apache 2.2
|
|
|
|
Order allow,deny
|
|
|
|
Allow from all
|
|
|
|
</IfModule>
|
|
|
|
|
|
|
|
SetEnv ICINGAWEB_CONFIGDIR "{configDir}"
|
|
|
|
|
|
|
|
EnableSendfile Off
|
|
|
|
|
|
|
|
<IfModule mod_rewrite.c>
|
|
|
|
RewriteEngine on
|
|
|
|
RewriteBase {urlPath}/
|
|
|
|
RewriteCond %{REQUEST_FILENAME} -s [OR]
|
|
|
|
RewriteCond %{REQUEST_FILENAME} -l [OR]
|
|
|
|
RewriteCond %{REQUEST_FILENAME} -d
|
|
|
|
RewriteRule ^.*$ - [NC,L]
|
|
|
|
RewriteRule ^.*$ index.php [NC,L]
|
|
|
|
</IfModule>
|
|
|
|
|
|
|
|
<IfModule !mod_rewrite.c>
|
|
|
|
DirectoryIndex error_norewrite.html
|
|
|
|
ErrorDocument 404 {urlPath}/error_norewrite.html
|
|
|
|
</IfModule>
|
|
|
|
|
|
|
|
<IfVersion >= 2.4>
|
|
|
|
# Forward PHP requests to FPM
|
|
|
|
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
|
|
|
|
<FilesMatch "\.php$">
|
|
|
|
SetHandler "proxy:{fpmUri}"
|
|
|
|
ErrorDocument 503 {urlPath}/error_unavailable.html
|
|
|
|
</FilesMatch>
|
|
|
|
</IfVersion>
|
|
|
|
</Directory>
|
|
|
|
EOD;
|
|
|
|
}
|
2014-11-05 15:32:09 +01:00
|
|
|
}
|
|
|
|
}
|