try to implement ssl-redirect for froxlor-vhost; combine various settings that are froxlor-vhost related into its own category, fixes #1480
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -69,14 +69,6 @@ return array(
|
|||||||
'save_method' => 'storeSettingHostname',
|
'save_method' => 'storeSettingHostname',
|
||||||
'plausibility_check_method' => 'checkHostname',
|
'plausibility_check_method' => 'checkHostname',
|
||||||
),
|
),
|
||||||
'system_froxlordirectlyviahostname' => array(
|
|
||||||
'label' => $lng['serversettings']['froxlordirectlyviahostname'],
|
|
||||||
'settinggroup' => 'system',
|
|
||||||
'varname' => 'froxlordirectlyviahostname',
|
|
||||||
'type' => 'bool',
|
|
||||||
'default' => false,
|
|
||||||
'save_method' => 'storeSettingField',
|
|
||||||
),
|
|
||||||
'system_validatedomain' => array(
|
'system_validatedomain' => array(
|
||||||
'label' => $lng['serversettings']['validate_domain'],
|
'label' => $lng['serversettings']['validate_domain'],
|
||||||
'settinggroup' => 'system',
|
'settinggroup' => 'system',
|
||||||
|
|||||||
163
actions/admin/settings/122.froxlorvhost.php
Normal file
163
actions/admin/settings/122.froxlorvhost.php
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2016 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2016-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Settings
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
return array(
|
||||||
|
'groups' => array(
|
||||||
|
'froxlorvhost' => array(
|
||||||
|
'title' => $lng['admin']['froxlorvhost'],
|
||||||
|
'fields' => array(
|
||||||
|
/**
|
||||||
|
* Webserver-Vhost
|
||||||
|
*/
|
||||||
|
'system_froxlordirectlyviahostname' => array(
|
||||||
|
'label' => $lng['serversettings']['froxlordirectlyviahostname'],
|
||||||
|
'settinggroup' => 'system',
|
||||||
|
'varname' => 'froxlordirectlyviahostname',
|
||||||
|
'type' => 'bool',
|
||||||
|
'default' => false,
|
||||||
|
'save_method' => 'storeSettingField'
|
||||||
|
),
|
||||||
|
/**
|
||||||
|
* SSL / Let's Encrypt
|
||||||
|
*/
|
||||||
|
'system_le_froxlor_enabled' => array(
|
||||||
|
'label' => $lng['serversettings']['le_froxlor_enabled'],
|
||||||
|
'settinggroup' => 'system',
|
||||||
|
'varname' => 'le_froxlor_enabled',
|
||||||
|
'type' => 'bool',
|
||||||
|
'default' => false,
|
||||||
|
'save_method' => 'storeSettingField',
|
||||||
|
'visible' => Settings::Get('system.leenabled')
|
||||||
|
),
|
||||||
|
'system_le_froxlor_redirect' => array(
|
||||||
|
'label' => $lng['serversettings']['le_froxlor_redirect'],
|
||||||
|
'settinggroup' => 'system',
|
||||||
|
'varname' => 'le_froxlor_redirect',
|
||||||
|
'type' => 'bool',
|
||||||
|
'default' => false,
|
||||||
|
'save_method' => 'storeSettingField',
|
||||||
|
'visible' => Settings::Get('system.leenabled')
|
||||||
|
),
|
||||||
|
/**
|
||||||
|
* FCGID
|
||||||
|
*/
|
||||||
|
'system_mod_fcgid_enabled_ownvhost' => array(
|
||||||
|
'label' => $lng['serversettings']['mod_fcgid_ownvhost'],
|
||||||
|
'settinggroup' => 'system',
|
||||||
|
'varname' => 'mod_fcgid_ownvhost',
|
||||||
|
'type' => 'bool',
|
||||||
|
'default' => true,
|
||||||
|
'save_method' => 'storeSettingField',
|
||||||
|
'websrv_avail' => array(
|
||||||
|
'apache2'
|
||||||
|
),
|
||||||
|
'visible' => Settings::Get('system.mod_fcgid')
|
||||||
|
),
|
||||||
|
'system_mod_fcgid_httpuser' => array(
|
||||||
|
'label' => $lng['admin']['mod_fcgid_user'],
|
||||||
|
'settinggroup' => 'system',
|
||||||
|
'varname' => 'mod_fcgid_httpuser',
|
||||||
|
'type' => 'string',
|
||||||
|
'default' => 'froxlorlocal',
|
||||||
|
'save_method' => 'storeSettingWebserverFcgidFpmUser',
|
||||||
|
'websrv_avail' => array(
|
||||||
|
'apache2'
|
||||||
|
),
|
||||||
|
'visible' => Settings::Get('system.mod_fcgid')
|
||||||
|
),
|
||||||
|
'system_mod_fcgid_httpgroup' => array(
|
||||||
|
'label' => $lng['admin']['mod_fcgid_group'],
|
||||||
|
'settinggroup' => 'system',
|
||||||
|
'varname' => 'mod_fcgid_httpgroup',
|
||||||
|
'type' => 'string',
|
||||||
|
'default' => 'froxlorlocal',
|
||||||
|
'save_method' => 'storeSettingField',
|
||||||
|
'websrv_avail' => array(
|
||||||
|
'apache2'
|
||||||
|
),
|
||||||
|
'visible' => Settings::Get('system.mod_fcgid')
|
||||||
|
),
|
||||||
|
'system_mod_fcgid_defaultini_ownvhost' => array(
|
||||||
|
'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'],
|
||||||
|
'settinggroup' => 'system',
|
||||||
|
'varname' => 'mod_fcgid_defaultini_ownvhost',
|
||||||
|
'type' => 'option',
|
||||||
|
'default' => '2',
|
||||||
|
'option_mode' => 'one',
|
||||||
|
'option_options_method' => 'getPhpConfigs',
|
||||||
|
'save_method' => 'storeSettingField',
|
||||||
|
'websrv_avail' => array(
|
||||||
|
'apache2'
|
||||||
|
),
|
||||||
|
'visible' => Settings::Get('system.mod_fcgid')
|
||||||
|
),
|
||||||
|
/**
|
||||||
|
* php-fpm
|
||||||
|
*/
|
||||||
|
'system_phpfpm_enabled_ownvhost' => array(
|
||||||
|
'label' => $lng['phpfpm']['ownvhost'],
|
||||||
|
'settinggroup' => 'phpfpm',
|
||||||
|
'varname' => 'enabled_ownvhost',
|
||||||
|
'type' => 'bool',
|
||||||
|
'default' => true,
|
||||||
|
'save_method' => 'storeSettingField',
|
||||||
|
'visible' => Settings::Get('phpfpm.enabled')
|
||||||
|
),
|
||||||
|
'system_phpfpm_httpuser' => array(
|
||||||
|
'label' => $lng['phpfpm']['vhost_httpuser'],
|
||||||
|
'settinggroup' => 'phpfpm',
|
||||||
|
'varname' => 'vhost_httpuser',
|
||||||
|
'type' => 'string',
|
||||||
|
'default' => 'froxlorlocal',
|
||||||
|
'save_method' => 'storeSettingWebserverFcgidFpmUser',
|
||||||
|
'visible' => Settings::Get('phpfpm.enabled')
|
||||||
|
),
|
||||||
|
'system_phpfpm_httpgroup' => array(
|
||||||
|
'label' => $lng['phpfpm']['vhost_httpgroup'],
|
||||||
|
'settinggroup' => 'phpfpm',
|
||||||
|
'varname' => 'vhost_httpgroup',
|
||||||
|
'type' => 'string',
|
||||||
|
'default' => 'froxlorlocal',
|
||||||
|
'save_method' => 'storeSettingField',
|
||||||
|
'visible' => Settings::Get('phpfpm.enabled')
|
||||||
|
),
|
||||||
|
'system_phpfpm_defaultini_ownvhost' => array(
|
||||||
|
'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'],
|
||||||
|
'settinggroup' => 'phpfpm',
|
||||||
|
'varname' => 'vhost_defaultini',
|
||||||
|
'type' => 'option',
|
||||||
|
'default' => '2',
|
||||||
|
'option_mode' => 'one',
|
||||||
|
'option_options_method' => 'getPhpConfigs',
|
||||||
|
'save_method' => 'storeSettingField',
|
||||||
|
'visible' => Settings::Get('phpfpm.enabled')
|
||||||
|
),
|
||||||
|
/**
|
||||||
|
* DNS
|
||||||
|
*/
|
||||||
|
'system_dns_createhostnameentry' => array(
|
||||||
|
'label' => $lng['serversettings']['dns_createhostnameentry'],
|
||||||
|
'settinggroup' => 'system',
|
||||||
|
'varname' => 'dns_createhostnameentry',
|
||||||
|
'type' => 'bool',
|
||||||
|
'default' => false,
|
||||||
|
'save_method' => 'storeSettingField',
|
||||||
|
'visible' => Settings::Get('system.bind_enable')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
* @package Settings
|
* @package Settings
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'groups' => array(
|
'groups' => array(
|
||||||
'ssl' => array(
|
'ssl' => array(
|
||||||
@@ -38,7 +37,7 @@ return array(
|
|||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'string_emptyallowed' => false,
|
'string_emptyallowed' => false,
|
||||||
'default' => 'ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128',
|
'default' => 'ECDH+AESGCM:ECDH+AES256:!aNULL:!MD5:!DSS:!DH:!AES128',
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_ssl_cert_file' => array(
|
'system_ssl_cert_file' => array(
|
||||||
'label' => $lng['serversettings']['ssl']['ssl_cert_file'],
|
'label' => $lng['serversettings']['ssl']['ssl_cert_file'],
|
||||||
@@ -48,7 +47,7 @@ return array(
|
|||||||
'string_type' => 'file',
|
'string_type' => 'file',
|
||||||
'string_emptyallowed' => true,
|
'string_emptyallowed' => true,
|
||||||
'default' => '/etc/apache2/apache2.pem',
|
'default' => '/etc/apache2/apache2.pem',
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_ssl_key_file' => array(
|
'system_ssl_key_file' => array(
|
||||||
'label' => $lng['serversettings']['ssl']['ssl_key_file'],
|
'label' => $lng['serversettings']['ssl']['ssl_key_file'],
|
||||||
@@ -58,7 +57,7 @@ return array(
|
|||||||
'string_type' => 'file',
|
'string_type' => 'file',
|
||||||
'string_emptyallowed' => true,
|
'string_emptyallowed' => true,
|
||||||
'default' => '/etc/apache2/apache2.key',
|
'default' => '/etc/apache2/apache2.key',
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_ssl_cert_chainfile' => array(
|
'system_ssl_cert_chainfile' => array(
|
||||||
'label' => $lng['admin']['ipsandports']['ssl_cert_chainfile'],
|
'label' => $lng['admin']['ipsandports']['ssl_cert_chainfile'],
|
||||||
@@ -68,7 +67,7 @@ return array(
|
|||||||
'string_type' => 'file',
|
'string_type' => 'file',
|
||||||
'string_emptyallowed' => true,
|
'string_emptyallowed' => true,
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_ssl_ca_file' => array(
|
'system_ssl_ca_file' => array(
|
||||||
'label' => $lng['serversettings']['ssl']['ssl_ca_file'],
|
'label' => $lng['serversettings']['ssl']['ssl_ca_file'],
|
||||||
@@ -78,7 +77,7 @@ return array(
|
|||||||
'string_type' => 'file',
|
'string_type' => 'file',
|
||||||
'string_emptyallowed' => true,
|
'string_emptyallowed' => true,
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_leenabled' => array(
|
'system_leenabled' => array(
|
||||||
'label' => $lng['serversettings']['leenabled'],
|
'label' => $lng['serversettings']['leenabled'],
|
||||||
@@ -89,22 +88,6 @@ return array(
|
|||||||
'cronmodule' => 'froxlor/letsencrypt',
|
'cronmodule' => 'froxlor/letsencrypt',
|
||||||
'save_method' => 'storeSettingField'
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_le_froxlor_enabled' => array(
|
|
||||||
'label' => $lng['serversettings']['le_froxlor_enabled'],
|
|
||||||
'settinggroup' => 'system',
|
|
||||||
'varname' => 'le_froxlor_enabled',
|
|
||||||
'type' => 'bool',
|
|
||||||
'default' => false,
|
|
||||||
'save_method' => 'storeSettingField'
|
|
||||||
),
|
|
||||||
'system_le_froxlor_redirect' => array(
|
|
||||||
'label' => $lng['serversettings']['le_froxlor_redirect'],
|
|
||||||
'settinggroup' => 'system',
|
|
||||||
'varname' => 'le_froxlor_redirect',
|
|
||||||
'type' => 'bool',
|
|
||||||
'default' => false,
|
|
||||||
'save_method' => 'storeSettingField'
|
|
||||||
),
|
|
||||||
'system_letsencryptca' => array(
|
'system_letsencryptca' => array(
|
||||||
'label' => $lng['serversettings']['letsencryptca'],
|
'label' => $lng['serversettings']['letsencryptca'],
|
||||||
'settinggroup' => 'system',
|
'settinggroup' => 'system',
|
||||||
@@ -112,8 +95,11 @@ return array(
|
|||||||
'type' => 'option',
|
'type' => 'option',
|
||||||
'default' => 'testing',
|
'default' => 'testing',
|
||||||
'option_mode' => 'one',
|
'option_mode' => 'one',
|
||||||
'option_options' => array('testing' => 'https://acme-staging.api.letsencrypt.org (Test)', 'production' => 'https://acme-v01.api.letsencrypt.org (Live)'),
|
'option_options' => array(
|
||||||
'save_method' => 'storeSettingField',
|
'testing' => 'https://acme-staging.api.letsencrypt.org (Test)',
|
||||||
|
'production' => 'https://acme-v01.api.letsencrypt.org (Live)'
|
||||||
|
),
|
||||||
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_letsencryptcountrycode' => array(
|
'system_letsencryptcountrycode' => array(
|
||||||
'label' => $lng['serversettings']['letsencryptcountrycode'],
|
'label' => $lng['serversettings']['letsencryptcountrycode'],
|
||||||
@@ -122,7 +108,7 @@ return array(
|
|||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'string_emptyallowed' => false,
|
'string_emptyallowed' => false,
|
||||||
'default' => 'DE',
|
'default' => 'DE',
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_letsencryptstate' => array(
|
'system_letsencryptstate' => array(
|
||||||
'label' => $lng['serversettings']['letsencryptstate'],
|
'label' => $lng['serversettings']['letsencryptstate'],
|
||||||
@@ -131,7 +117,7 @@ return array(
|
|||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'string_emptyallowed' => false,
|
'string_emptyallowed' => false,
|
||||||
'default' => 'Hessen',
|
'default' => 'Hessen',
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_letsencryptchallengepath' => array(
|
'system_letsencryptchallengepath' => array(
|
||||||
'label' => $lng['serversettings']['letsencryptchallengepath'],
|
'label' => $lng['serversettings']['letsencryptchallengepath'],
|
||||||
@@ -140,7 +126,7 @@ return array(
|
|||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'string_emptyallowed' => false,
|
'string_emptyallowed' => false,
|
||||||
'default' => FROXLOR_INSTALL_DIR,
|
'default' => FROXLOR_INSTALL_DIR,
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_letsencryptkeysize' => array(
|
'system_letsencryptkeysize' => array(
|
||||||
'label' => $lng['serversettings']['letsencryptkeysize'],
|
'label' => $lng['serversettings']['letsencryptkeysize'],
|
||||||
@@ -149,7 +135,7 @@ return array(
|
|||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
'int_min' => 2048,
|
'int_min' => 2048,
|
||||||
'default' => 4096,
|
'default' => 4096,
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_letsencryptreuseold' => array(
|
'system_letsencryptreuseold' => array(
|
||||||
'label' => $lng['serversettings']['letsencryptreuseold'],
|
'label' => $lng['serversettings']['letsencryptreuseold'],
|
||||||
@@ -157,8 +143,8 @@ return array(
|
|||||||
'varname' => 'letsencryptreuseold',
|
'varname' => 'letsencryptreuseold',
|
||||||
'type' => 'bool',
|
'type' => 'bool',
|
||||||
'default' => false,
|
'default' => false,
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField'
|
||||||
),
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -97,44 +97,6 @@ return array(
|
|||||||
'option_options_method' => 'getPhpConfigs',
|
'option_options_method' => 'getPhpConfigs',
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField',
|
||||||
),
|
),
|
||||||
'system_mod_fcgid_enabled_ownvhost' => array(
|
|
||||||
'label' => $lng['serversettings']['mod_fcgid_ownvhost'],
|
|
||||||
'settinggroup' => 'system',
|
|
||||||
'varname' => 'mod_fcgid_ownvhost',
|
|
||||||
'type' => 'bool',
|
|
||||||
'default' => true,
|
|
||||||
'save_method' => 'storeSettingField',
|
|
||||||
'websrv_avail' => array('apache2')
|
|
||||||
),
|
|
||||||
'system_mod_fcgid_httpuser' => array(
|
|
||||||
'label' => $lng['admin']['mod_fcgid_user'],
|
|
||||||
'settinggroup' => 'system',
|
|
||||||
'varname' => 'mod_fcgid_httpuser',
|
|
||||||
'type' => 'string',
|
|
||||||
'default' => 'froxlorlocal',
|
|
||||||
'save_method' => 'storeSettingWebserverFcgidFpmUser',
|
|
||||||
'websrv_avail' => array('apache2')
|
|
||||||
),
|
|
||||||
'system_mod_fcgid_httpgroup' => array(
|
|
||||||
'label' => $lng['admin']['mod_fcgid_group'],
|
|
||||||
'settinggroup' => 'system',
|
|
||||||
'varname' => 'mod_fcgid_httpgroup',
|
|
||||||
'type' => 'string',
|
|
||||||
'default' => 'froxlorlocal',
|
|
||||||
'save_method' => 'storeSettingField',
|
|
||||||
'websrv_avail' => array('apache2')
|
|
||||||
),
|
|
||||||
'system_mod_fcgid_defaultini_ownvhost' => array(
|
|
||||||
'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'],
|
|
||||||
'settinggroup' => 'system',
|
|
||||||
'varname' => 'mod_fcgid_defaultini_ownvhost',
|
|
||||||
'type' => 'option',
|
|
||||||
'default' => '2',
|
|
||||||
'option_mode' => 'one',
|
|
||||||
'option_options_method' => 'getPhpConfigs',
|
|
||||||
'save_method' => 'storeSettingField',
|
|
||||||
'websrv_avail' => array('apache2')
|
|
||||||
),
|
|
||||||
'system_mod_fcgid_idle_timeout' => array(
|
'system_mod_fcgid_idle_timeout' => array(
|
||||||
'label' => $lng['serversettings']['mod_fcgid']['idle_timeout'],
|
'label' => $lng['serversettings']['mod_fcgid']['idle_timeout'],
|
||||||
'settinggroup' => 'system',
|
'settinggroup' => 'system',
|
||||||
|
|||||||
@@ -30,30 +30,6 @@ return array(
|
|||||||
'plausibility_check_method' => 'checkFcgidPhpFpm',
|
'plausibility_check_method' => 'checkFcgidPhpFpm',
|
||||||
'overview_option' => true
|
'overview_option' => true
|
||||||
),
|
),
|
||||||
'system_phpfpm_enabled_ownvhost' => array(
|
|
||||||
'label' => $lng['phpfpm']['ownvhost'],
|
|
||||||
'settinggroup' => 'phpfpm',
|
|
||||||
'varname' => 'enabled_ownvhost',
|
|
||||||
'type' => 'bool',
|
|
||||||
'default' => true,
|
|
||||||
'save_method' => 'storeSettingField'
|
|
||||||
),
|
|
||||||
'system_phpfpm_httpuser' => array(
|
|
||||||
'label' => $lng['phpfpm']['vhost_httpuser'],
|
|
||||||
'settinggroup' => 'phpfpm',
|
|
||||||
'varname' => 'vhost_httpuser',
|
|
||||||
'type' => 'string',
|
|
||||||
'default' => 'froxlorlocal',
|
|
||||||
'save_method' => 'storeSettingWebserverFcgidFpmUser'
|
|
||||||
),
|
|
||||||
'system_phpfpm_httpgroup' => array(
|
|
||||||
'label' => $lng['phpfpm']['vhost_httpgroup'],
|
|
||||||
'settinggroup' => 'phpfpm',
|
|
||||||
'varname' => 'vhost_httpgroup',
|
|
||||||
'type' => 'string',
|
|
||||||
'default' => 'froxlorlocal',
|
|
||||||
'save_method' => 'storeSettingField'
|
|
||||||
),
|
|
||||||
'system_phpfpm_defaultini' => array(
|
'system_phpfpm_defaultini' => array(
|
||||||
'label' => $lng['serversettings']['mod_fcgid']['defaultini'],
|
'label' => $lng['serversettings']['mod_fcgid']['defaultini'],
|
||||||
'settinggroup' => 'phpfpm',
|
'settinggroup' => 'phpfpm',
|
||||||
@@ -64,16 +40,6 @@ return array(
|
|||||||
'option_options_method' => 'getPhpConfigs',
|
'option_options_method' => 'getPhpConfigs',
|
||||||
'save_method' => 'storeSettingField'
|
'save_method' => 'storeSettingField'
|
||||||
),
|
),
|
||||||
'system_phpfpm_defaultini_ownvhost' => array(
|
|
||||||
'label' => $lng['serversettings']['mod_fcgid']['defaultini_ownvhost'],
|
|
||||||
'settinggroup' => 'phpfpm',
|
|
||||||
'varname' => 'vhost_defaultini',
|
|
||||||
'type' => 'option',
|
|
||||||
'default' => '2',
|
|
||||||
'option_mode' => 'one',
|
|
||||||
'option_options_method' => 'getPhpConfigs',
|
|
||||||
'save_method' => 'storeSettingField'
|
|
||||||
),
|
|
||||||
'system_phpfpm_configdir' => array(
|
'system_phpfpm_configdir' => array(
|
||||||
'label' => $lng['serversettings']['phpfpm_settings']['configdir'],
|
'label' => $lng['serversettings']['phpfpm_settings']['configdir'],
|
||||||
'settinggroup' => 'phpfpm',
|
'settinggroup' => 'phpfpm',
|
||||||
|
|||||||
@@ -97,14 +97,6 @@ return array(
|
|||||||
'default' => '',
|
'default' => '',
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField',
|
||||||
),
|
),
|
||||||
'system_dns_createhostnameentry' => array(
|
|
||||||
'label' => $lng['serversettings']['dns_createhostnameentry'],
|
|
||||||
'settinggroup' => 'system',
|
|
||||||
'varname' => 'dns_createhostnameentry',
|
|
||||||
'type' => 'bool',
|
|
||||||
'default' => false,
|
|
||||||
'save_method' => 'storeSettingField'
|
|
||||||
),
|
|
||||||
'system_dns_createmailentry' => array(
|
'system_dns_createmailentry' => array(
|
||||||
'label' => $lng['serversettings']['mail_also_with_mxservers'],
|
'label' => $lng['serversettings']['mail_also_with_mxservers'],
|
||||||
'settinggroup' => 'system',
|
'settinggroup' => 'system',
|
||||||
@@ -127,5 +119,3 @@ return array(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
|
||||||
@@ -46,7 +46,7 @@ class DomainSSL {
|
|||||||
|| $dom_certs['ssl_cert_file'] == ''
|
|| $dom_certs['ssl_cert_file'] == ''
|
||||||
) {
|
) {
|
||||||
// maybe its parent?
|
// maybe its parent?
|
||||||
if ($domain['parentdomainid'] != 0) {
|
if (isset($domain['parentdomainid']) && $domain['parentdomainid'] != 0) {
|
||||||
$dom_certs = Database::pexecute_first($dom_certs_stmt, array('domid' => $domain['parentdomainid']));
|
$dom_certs = Database::pexecute_first($dom_certs_stmt, array('domid' => $domain['parentdomainid']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2036,3 +2036,4 @@ $lng['serversettings']['le_froxlor_enabled']['title'] = "Enable Let's Encrypt fo
|
|||||||
$lng['serversettings']['le_froxlor_enabled']['description'] = "If activated, the froxlor vhost will automatically be secured using a Let's Encrypt certificate.";
|
$lng['serversettings']['le_froxlor_enabled']['description'] = "If activated, the froxlor vhost will automatically be secured using a Let's Encrypt certificate.";
|
||||||
$lng['serversettings']['le_froxlor_redirect']['title'] = "Enable SSL-redirect for the froxlor vhost";
|
$lng['serversettings']['le_froxlor_redirect']['title'] = "Enable SSL-redirect for the froxlor vhost";
|
||||||
$lng['serversettings']['le_froxlor_redirect']['description'] = "If activated, all http requests to your froxlor will be redirected to the corresponding SSL site.";
|
$lng['serversettings']['le_froxlor_redirect']['description'] = "If activated, all http requests to your froxlor will be redirected to the corresponding SSL site.";
|
||||||
|
$lng['admin']['froxlorvhost'] = 'Froxlor VirtualHost settings';
|
||||||
|
|||||||
@@ -1688,3 +1688,4 @@ $lng['serversettings']['le_froxlor_enabled']['title'] = "Let's Encrypt für den
|
|||||||
$lng['serversettings']['le_froxlor_enabled']['description'] = "Wenn dies aktiviert ist, erstellt froxlor für seinen vhost automatisch ein Let's Encrypt Zertifikat.";
|
$lng['serversettings']['le_froxlor_enabled']['description'] = "Wenn dies aktiviert ist, erstellt froxlor für seinen vhost automatisch ein Let's Encrypt Zertifikat.";
|
||||||
$lng['serversettings']['le_froxlor_redirect']['title'] = "SSL-Weiterleitung für den froxlor Vhost aktivieren";
|
$lng['serversettings']['le_froxlor_redirect']['title'] = "SSL-Weiterleitung für den froxlor Vhost aktivieren";
|
||||||
$lng['serversettings']['le_froxlor_redirect']['description'] = "Wenn dies aktiviert ist, werden alle HTTP Anfragen an die entsprechende SSL Seite weitergeleitet.";
|
$lng['serversettings']['le_froxlor_redirect']['description'] = "Wenn dies aktiviert ist, werden alle HTTP Anfragen an die entsprechende SSL Seite weitergeleitet.";
|
||||||
|
$lng['admin']['froxlorvhost'] = 'Froxlor VirtualHost Einstellungen';
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/***
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2016 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2016-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Cron
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
* Class DnsBase
|
* Class DnsBase
|
||||||
*
|
*
|
||||||
* Base class for all DNS server configs
|
* Base class for all DNS server configs
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
abstract class DnsBase
|
abstract class DnsBase
|
||||||
{
|
{
|
||||||
@@ -69,8 +83,7 @@ abstract class DnsBase
|
|||||||
|
|
||||||
protected function getDomainList()
|
protected function getDomainList()
|
||||||
{
|
{
|
||||||
$result_domains_stmt = Database::query(
|
$result_domains_stmt = Database::query("
|
||||||
"
|
|
||||||
SELECT
|
SELECT
|
||||||
`d`.`id`,
|
`d`.`id`,
|
||||||
`d`.`domain`,
|
`d`.`domain`,
|
||||||
@@ -134,28 +147,14 @@ abstract class DnsBase
|
|||||||
if (isset($domains[$domains[$key]['ismainbutsubto']])) {
|
if (isset($domains[$domains[$key]['ismainbutsubto']])) {
|
||||||
$domains[$domains[$key]['ismainbutsubto']]['children'][] = $domains[$key]['id'];
|
$domains[$domains[$key]['ismainbutsubto']]['children'][] = $domains[$key]['id'];
|
||||||
} else {
|
} else {
|
||||||
$this->_logger->logAction(CRON_ACTION, LOG_ERR,
|
$this->_logger->logAction(CRON_ACTION, LOG_ERR, 'Database inconsistency: domain ' . $domain['domain'] . ' (ID #' . $key . ') is set to to be subdomain to non-existent domain ID #' . $domains[$key]['ismainbutsubto'] . '. No DNS record(s) will be created for this domain.');
|
||||||
'Database inconsistency: domain ' . $domain['domain'] . ' (ID #' . $key .
|
|
||||||
') is set to to be subdomain to non-existent domain ID #' .
|
|
||||||
$domains[$key]['ismainbutsubto'] .
|
|
||||||
'. No DNS record(s) will be created for this domain.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_logger->logAction(CRON_ACTION, LOG_DEBUG,
|
$this->_logger->logAction(CRON_ACTION, LOG_DEBUG, str_pad('domId', 9, ' ') . str_pad('domain', 40, ' ') . 'ismainbutsubto ' . str_pad('parent domain', 40, ' ') . "list of child domain ids");
|
||||||
str_pad('domId', 9, ' ') . str_pad('domain', 40, ' ') .
|
|
||||||
'ismainbutsubto ' . str_pad('parent domain', 40, ' ') .
|
|
||||||
"list of child domain ids");
|
|
||||||
foreach ($domains as $domain) {
|
foreach ($domains as $domain) {
|
||||||
$logLine =
|
$logLine = str_pad($domain['id'], 9, ' ') . str_pad($domain['domain'], 40, ' ') . str_pad($domain['ismainbutsubto'], 15, ' ') . str_pad(((isset($domains[$domain['ismainbutsubto']])) ? $domains[$domain['ismainbutsubto']]['domain'] : '-'), 40, ' ') . join(', ', $domain['children']);
|
||||||
str_pad($domain['id'], 9, ' ') .
|
|
||||||
str_pad($domain['domain'], 40, ' ') .
|
|
||||||
str_pad($domain['ismainbutsubto'], 15, ' ') .
|
|
||||||
str_pad(((isset($domains[ $domain['ismainbutsubto'] ])) ?
|
|
||||||
$domains[ $domain['ismainbutsubto'] ]['domain'] :
|
|
||||||
'-'), 40, ' ') .
|
|
||||||
join(', ', $domain['children']);
|
|
||||||
$this->_logger->logAction(CRON_ACTION, LOG_DEBUG, $logLine);
|
$this->_logger->logAction(CRON_ACTION, LOG_DEBUG, $logLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,8 +170,7 @@ abstract class DnsBase
|
|||||||
if ($cmdStatus === 0) {
|
if ($cmdStatus === 0) {
|
||||||
$this->_logger->logAction(CRON_ACTION, LOG_INFO, Settings::Get('system.dns_server') . ' daemon reloaded');
|
$this->_logger->logAction(CRON_ACTION, LOG_INFO, Settings::Get('system.dns_server') . ' daemon reloaded');
|
||||||
} else {
|
} else {
|
||||||
$this->_logger->logAction(CRON_ACTION, LOG_ERR, 'Error while running `' . $cmd .
|
$this->_logger->logAction(CRON_ACTION, LOG_ERR, 'Error while running `' . $cmd . '`: exit code (' . $cmdStatus . ') - please check your system logs');
|
||||||
'`: exit code (' . $cmdStatus . ') - please check your system logs');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
/***
|
|
||||||
|
/**
|
||||||
|
* This file is part of the Froxlor project.
|
||||||
|
* Copyright (c) 2016 the Froxlor Team (see authors).
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the COPYING
|
||||||
|
* file that was distributed with this source code. You can also view the
|
||||||
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
*
|
||||||
|
* @copyright (c) the authors
|
||||||
|
* @author Froxlor team <team@froxlor.org> (2016-)
|
||||||
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||||
|
* @package Cron
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
* Class HttpConfigBase
|
* Class HttpConfigBase
|
||||||
*
|
*
|
||||||
* Base class for all HTTP server configs
|
* Base class for all HTTP server configs
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class HttpConfigBase {
|
class HttpConfigBase
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* process special config as template, by substituting {VARIABLE} with the
|
* process special config as template, by substituting {VARIABLE} with the
|
||||||
@@ -20,10 +37,12 @@ class HttpConfigBase {
|
|||||||
* {IS_SSL} - evaluates to 'ssl' if domain/ip is ssl, otherwise it is an empty string
|
* {IS_SSL} - evaluates to 'ssl' if domain/ip is ssl, otherwise it is an empty string
|
||||||
* {DOCROOT} - document root for this domain
|
* {DOCROOT} - document root for this domain
|
||||||
*
|
*
|
||||||
* @param $template
|
* @param
|
||||||
|
* $template
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function processSpecialConfigTemplate($template, $domain, $ip, $port, $is_ssl_vhost) {
|
protected function processSpecialConfigTemplate($template, $domain, $ip, $port, $is_ssl_vhost)
|
||||||
|
{
|
||||||
$templateVars = array(
|
$templateVars = array(
|
||||||
'DOMAIN' => $domain['domain'],
|
'DOMAIN' => $domain['domain'],
|
||||||
'CUSTOMER' => $domain['loginname'],
|
'CUSTOMER' => $domain['loginname'],
|
||||||
@@ -35,4 +54,68 @@ class HttpConfigBase {
|
|||||||
return replace_variables($template, $templateVars);
|
return replace_variables($template, $templateVars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getMyPath($ip_port = null)
|
||||||
|
{
|
||||||
|
if (! empty($ip_port) && $ip_port['docroot'] == '') {
|
||||||
|
if (Settings::Get('system.froxlordirectlyviahostname')) {
|
||||||
|
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
|
||||||
|
} else {
|
||||||
|
$mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// user-defined docroot, #417
|
||||||
|
$mypath = makeCorrectDir($row_ipsandports['docroot']);
|
||||||
|
}
|
||||||
|
return $mypath;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function checkAlternativeSslPort()
|
||||||
|
{
|
||||||
|
// We must not check if our port differs from port 443,
|
||||||
|
// but if there is a destination-port != 443
|
||||||
|
$_sslport = '';
|
||||||
|
// This returns the first port that is != 443 with ssl enabled,
|
||||||
|
// ordered by ssl-certificate (if any) so that the ip/port combo
|
||||||
|
// with certificate is used
|
||||||
|
$ssldestport_stmt = Database::prepare("
|
||||||
|
SELECT `ip`.`port` FROM " . TABLE_PANEL_IPSANDPORTS . " `ip`
|
||||||
|
WHERE `ip`.`ssl` = '1' AND `ip`.`port` != 443
|
||||||
|
ORDER BY `ip`.`ssl_cert_file` DESC, `ip`.`port` LIMIT 1;
|
||||||
|
");
|
||||||
|
$ssldestport = Database::pexecute_first($ssldestport_stmt);
|
||||||
|
|
||||||
|
if ($ssldestport['port'] != '') {
|
||||||
|
$_sslport = ":" . $ssldestport['port'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $_sslport;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function froxlorVhostHasLetsEncryptCert()
|
||||||
|
{
|
||||||
|
// check whether we have an entry with valid certificates which just does not need
|
||||||
|
// updating yet, so we need to skip this here
|
||||||
|
$froxlor_ssl_settings_stmt = Database::prepare("
|
||||||
|
SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = '0'
|
||||||
|
");
|
||||||
|
$froxlor_ssl = Database::pexecute_first($froxlor_ssl_settings_stmt);
|
||||||
|
if ($froxlor_ssl && ! empty($froxlor_ssl['ssl_cert_file'])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function froxlorVhostLetsEncryptNeedsRenew()
|
||||||
|
{
|
||||||
|
$froxlor_ssl_settings_stmt = Database::prepare("
|
||||||
|
SELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "`
|
||||||
|
WHERE `domainid` = '0' AND
|
||||||
|
(`expirationdate` < DATE_ADD(NOW(), INTERVAL 30 DAY) OR `expirationdate` IS NULL)
|
||||||
|
");
|
||||||
|
$froxlor_ssl = Database::pexecute_first($froxlor_ssl_settings_stmt);
|
||||||
|
if ($froxlor_ssl && ! empty($froxlor_ssl['ssl_cert_file'])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -27,8 +27,7 @@ if (! extension_loaded('curl')) {
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$certificates_stmt = Database::query(
|
$certificates_stmt = Database::query("
|
||||||
"
|
|
||||||
SELECT
|
SELECT
|
||||||
domssl.`id`,
|
domssl.`id`,
|
||||||
domssl.`domainid`,
|
domssl.`domainid`,
|
||||||
@@ -63,8 +62,7 @@ $certificates_stmt = Database::query(
|
|||||||
)
|
)
|
||||||
");
|
");
|
||||||
|
|
||||||
$aliasdomains_stmt = Database::prepare(
|
$aliasdomains_stmt = Database::prepare("
|
||||||
"
|
|
||||||
SELECT
|
SELECT
|
||||||
dom.`id` as domainid,
|
dom.`id` as domainid,
|
||||||
dom.`domain`,
|
dom.`domain`,
|
||||||
@@ -76,8 +74,7 @@ $aliasdomains_stmt = Database::prepare(
|
|||||||
AND dom.`iswildcarddomain` = 0
|
AND dom.`iswildcarddomain` = 0
|
||||||
");
|
");
|
||||||
|
|
||||||
$updcert_stmt = Database::prepare(
|
$updcert_stmt = Database::prepare("
|
||||||
"
|
|
||||||
REPLACE INTO
|
REPLACE INTO
|
||||||
`" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "`
|
`" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "`
|
||||||
SET
|
SET
|
||||||
@@ -142,15 +139,14 @@ if (Settings::Get('system.le_froxlor_enabled') == '1') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($insert_or_update_required)
|
if ($insert_or_update_required) {
|
||||||
{
|
|
||||||
$domains = array(
|
$domains = array(
|
||||||
$certrow['domain'],
|
$certrow['domain'],
|
||||||
'www.' . $certrow['domain']
|
'www.' . $certrow['domain']
|
||||||
);
|
);
|
||||||
|
|
||||||
// Only renew let's encrypt certificate if no broken ssl_redirect is enabled
|
// Only renew let's encrypt certificate if no broken ssl_redirect is enabled
|
||||||
if ($certrow['ssl_redirect'] != 2) {
|
// - this temp. deactivation of the ssl-redirect is handled by the webserver-cronjob
|
||||||
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Updating " . $certrow['domain']);
|
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Updating " . $certrow['domain']);
|
||||||
|
|
||||||
$cronlog = FroxlorLogger::getInstanceOf(array(
|
$cronlog = FroxlorLogger::getInstanceOf(array(
|
||||||
@@ -171,8 +167,7 @@ if (Settings::Get('system.le_froxlor_enabled') == '1') {
|
|||||||
$newcert = openssl_x509_parse($return['crt']);
|
$newcert = openssl_x509_parse($return['crt']);
|
||||||
|
|
||||||
// Store the new data
|
// Store the new data
|
||||||
Database::pexecute($updcert_stmt,
|
Database::pexecute($updcert_stmt, array(
|
||||||
array(
|
|
||||||
'id' => $certrow['id'],
|
'id' => $certrow['id'],
|
||||||
'domainid' => $certrow['domainid'],
|
'domainid' => $certrow['domainid'],
|
||||||
'crt' => $return['crt'],
|
'crt' => $return['crt'],
|
||||||
@@ -191,12 +186,7 @@ if (Settings::Get('system.le_froxlor_enabled') == '1') {
|
|||||||
|
|
||||||
$changedetected = 1;
|
$changedetected = 1;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$cronlog->logAction(CRON_ACTION, LOG_ERR,
|
$cronlog->logAction(CRON_ACTION, LOG_ERR, "Could not get Let's Encrypt certificate for " . $certrow['domain'] . ": " . $e->getMessage());
|
||||||
"Could not get Let's Encrypt certificate for " . $certrow['domain'] . ": " . $e->getMessage());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$cronlog->logAction(CRON_ACTION, LOG_WARNING,
|
|
||||||
"Skipping Let's Encrypt generation for " . $certrow['domain'] . " due to an enabled ssl_redirect");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,8 +242,7 @@ foreach ($certrows as $certrow) {
|
|||||||
$newcert = openssl_x509_parse($return['crt']);
|
$newcert = openssl_x509_parse($return['crt']);
|
||||||
|
|
||||||
// Store the new data
|
// Store the new data
|
||||||
Database::pexecute($updcert_stmt,
|
Database::pexecute($updcert_stmt, array(
|
||||||
array(
|
|
||||||
'id' => $certrow['id'],
|
'id' => $certrow['id'],
|
||||||
'domainid' => $certrow['domainid'],
|
'domainid' => $certrow['domainid'],
|
||||||
'crt' => $return['crt'],
|
'crt' => $return['crt'],
|
||||||
@@ -274,12 +263,10 @@ foreach ($certrows as $certrow) {
|
|||||||
|
|
||||||
$changedetected = 1;
|
$changedetected = 1;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$cronlog->logAction(CRON_ACTION, LOG_ERR,
|
$cronlog->logAction(CRON_ACTION, LOG_ERR, "Could not get Let's Encrypt certificate for " . $certrow['domain'] . ": " . $e->getMessage());
|
||||||
"Could not get Let's Encrypt certificate for " . $certrow['domain'] . ": " . $e->getMessage());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$cronlog->logAction(CRON_ACTION, LOG_WARNING,
|
$cronlog->logAction(CRON_ACTION, LOG_WARNING, "Skipping Let's Encrypt generation for " . $certrow['domain'] . " due to an enabled ssl_redirect");
|
||||||
"Skipping Let's Encrypt generation for " . $certrow['domain'] . " due to an enabled ssl_redirect");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<?php if (!defined('MASTER_CRONJOB')) die('You cannot access this file directly!');
|
<?php
|
||||||
|
|
||||||
|
if (! defined('MASTER_CRONJOB'))
|
||||||
|
die('You cannot access this file directly!');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of the Froxlor project.
|
* This file is part of the Froxlor project.
|
||||||
@@ -19,16 +22,24 @@
|
|||||||
|
|
||||||
require_once (dirname(__FILE__) . '/../classes/class.HttpConfigBase.php');
|
require_once (dirname(__FILE__) . '/../classes/class.HttpConfigBase.php');
|
||||||
|
|
||||||
class apache extends HttpConfigBase {
|
class apache extends HttpConfigBase
|
||||||
|
{
|
||||||
|
|
||||||
private $logger = false;
|
private $logger = false;
|
||||||
|
|
||||||
private $idnaConvert = false;
|
private $idnaConvert = false;
|
||||||
|
|
||||||
// protected
|
// protected
|
||||||
protected $known_vhostfilenames = array();
|
protected $known_vhostfilenames = array();
|
||||||
|
|
||||||
protected $known_diroptionsfilenames = array();
|
protected $known_diroptionsfilenames = array();
|
||||||
|
|
||||||
protected $known_htpasswdsfilenames = array();
|
protected $known_htpasswdsfilenames = array();
|
||||||
|
|
||||||
protected $virtualhosts_data = array();
|
protected $virtualhosts_data = array();
|
||||||
|
|
||||||
protected $diroptions_data = array();
|
protected $diroptions_data = array();
|
||||||
|
|
||||||
protected $htpasswds_data = array();
|
protected $htpasswds_data = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,13 +50,14 @@ class apache extends HttpConfigBase {
|
|||||||
*/
|
*/
|
||||||
private $_deactivated = false;
|
private $_deactivated = false;
|
||||||
|
|
||||||
public function __construct($logger, $idnaConvert) {
|
public function __construct($logger, $idnaConvert)
|
||||||
|
{
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->idnaConvert = $idnaConvert;
|
$this->idnaConvert = $idnaConvert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function reload()
|
||||||
public function reload() {
|
{
|
||||||
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
if ((int) Settings::Get('phpfpm.enabled') == 1) {
|
||||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: reloading php-fpm');
|
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'apache::reload: reloading php-fpm');
|
||||||
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
|
safe_exec(escapeshellcmd(Settings::Get('phpfpm.reload')));
|
||||||
@@ -54,11 +66,11 @@ class apache extends HttpConfigBase {
|
|||||||
safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
|
safe_exec(escapeshellcmd(Settings::Get('system.apachereload_command')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define a standard <Directory>-statement, bug #32
|
* define a standard <Directory>-statement, bug #32
|
||||||
*/
|
*/
|
||||||
private function _createStandardDirectoryEntry() {
|
private function _createStandardDirectoryEntry()
|
||||||
|
{
|
||||||
$vhosts_folder = '';
|
$vhosts_folder = '';
|
||||||
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
|
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
|
||||||
$vhosts_folder = makeCorrectDir(Settings::Get('system.apacheconf_vhost'));
|
$vhosts_folder = makeCorrectDir(Settings::Get('system.apacheconf_vhost'));
|
||||||
@@ -67,9 +79,7 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
$vhosts_filename = makeCorrectFile($vhosts_folder . '/05_froxlor_dirfix_nofcgid.conf');
|
$vhosts_filename = makeCorrectFile($vhosts_folder . '/05_froxlor_dirfix_nofcgid.conf');
|
||||||
|
|
||||||
if (Settings::Get('system.mod_fcgid') == '1'
|
if (Settings::Get('system.mod_fcgid') == '1' || Settings::Get('phpfpm.enabled') == '1') {
|
||||||
|| Settings::Get('phpfpm.enabled') == '1'
|
|
||||||
) {
|
|
||||||
// if we use fcgid or php-fpm we don't need this file
|
// if we use fcgid or php-fpm we don't need this file
|
||||||
if (file_exists($vhosts_filename)) {
|
if (file_exists($vhosts_filename)) {
|
||||||
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename));
|
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'apache::_createStandardDirectoryEntry: unlinking ' . basename($vhosts_filename));
|
||||||
@@ -84,12 +94,9 @@ class apache extends HttpConfigBase {
|
|||||||
|
|
||||||
// check for custom values, see #1638
|
// check for custom values, see #1638
|
||||||
$custom_opts = Settings::Get('system.apacheglobaldiropt');
|
$custom_opts = Settings::Get('system.apacheglobaldiropt');
|
||||||
if (!empty($custom_opts))
|
if (! empty($custom_opts)) {
|
||||||
{
|
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= $custom_opts . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= $custom_opts . "\n";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// >=apache-2.4 enabled?
|
// >=apache-2.4 enabled?
|
||||||
if (Settings::Get('system.apache24') == '1') {
|
if (Settings::Get('system.apache24') == '1') {
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= ' Require all granted' . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' Require all granted' . "\n";
|
||||||
@@ -103,17 +110,12 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define a default ErrorDocument-statement, bug #unknown-yet
|
* define a default ErrorDocument-statement, bug #unknown-yet
|
||||||
*/
|
*/
|
||||||
private function _createStandardErrorHandler() {
|
private function _createStandardErrorHandler()
|
||||||
if (Settings::Get('defaultwebsrverrhandler.enabled') == '1'
|
{
|
||||||
&& (Settings::Get('defaultwebsrverrhandler.err401') != ''
|
if (Settings::Get('defaultwebsrverrhandler.enabled') == '1' && (Settings::Get('defaultwebsrverrhandler.err401') != '' || Settings::Get('defaultwebsrverrhandler.err403') != '' || Settings::Get('defaultwebsrverrhandler.err404') != '' || Settings::Get('defaultwebsrverrhandler.err500') != '')) {
|
||||||
|| Settings::Get('defaultwebsrverrhandler.err403') != ''
|
|
||||||
|| Settings::Get('defaultwebsrverrhandler.err404') != ''
|
|
||||||
|| Settings::Get('defaultwebsrverrhandler.err500') != '')
|
|
||||||
) {
|
|
||||||
$vhosts_folder = '';
|
$vhosts_folder = '';
|
||||||
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
|
if (is_dir(Settings::Get('system.apacheconf_vhost'))) {
|
||||||
$vhosts_folder = makeCorrectDir(Settings::Get('system.apacheconf_vhost'));
|
$vhosts_folder = makeCorrectDir(Settings::Get('system.apacheconf_vhost'));
|
||||||
@@ -127,7 +129,12 @@ class apache extends HttpConfigBase {
|
|||||||
$this->virtualhosts_data[$vhosts_filename] = '';
|
$this->virtualhosts_data[$vhosts_filename] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$statusCodes = array('401', '403', '404', '500');
|
$statusCodes = array(
|
||||||
|
'401',
|
||||||
|
'403',
|
||||||
|
'404',
|
||||||
|
'500'
|
||||||
|
);
|
||||||
foreach ($statusCodes as $statusCode) {
|
foreach ($statusCodes as $statusCode) {
|
||||||
if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') {
|
if (Settings::Get('defaultwebsrverrhandler.err' . $statusCode) != '') {
|
||||||
$defhandler = Settings::Get('defaultwebsrverrhandler.err' . $statusCode);
|
$defhandler = Settings::Get('defaultwebsrverrhandler.err' . $statusCode);
|
||||||
@@ -142,8 +149,8 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createIpPort()
|
||||||
public function createIpPort() {
|
{
|
||||||
$result_ipsandports_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC");
|
$result_ipsandports_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` ORDER BY `ip` ASC, `port` ASC");
|
||||||
|
|
||||||
while ($row_ipsandports = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row_ipsandports = $result_ipsandports_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
@@ -178,19 +185,7 @@ class apache extends HttpConfigBase {
|
|||||||
if ($row_ipsandports['vhostcontainer'] == '1') {
|
if ($row_ipsandports['vhostcontainer'] == '1') {
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= '<VirtualHost ' . $ipport . '>' . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= '<VirtualHost ' . $ipport . '>' . "\n";
|
||||||
|
|
||||||
if ($row_ipsandports['docroot'] == '') {
|
$mypath = $this->getMyPath($row_ipsandports);
|
||||||
/**
|
|
||||||
* add 'real'-vhost content here, like doc-root :)
|
|
||||||
*/
|
|
||||||
if (Settings::Get('system.froxlordirectlyviahostname')) {
|
|
||||||
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
|
|
||||||
} else {
|
|
||||||
$mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// user-defined docroot, #417
|
|
||||||
$mypath = makeCorrectDir($row_ipsandports['docroot']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= 'DocumentRoot "' . $mypath . '"' . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= 'DocumentRoot "' . $mypath . '"' . "\n";
|
||||||
|
|
||||||
@@ -198,10 +193,40 @@ class apache extends HttpConfigBase {
|
|||||||
$this->virtualhosts_data[$vhosts_filename] .= ' ServerName ' . Settings::Get('system.hostname') . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' ServerName ' . Settings::Get('system.hostname') . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$is_redirect = false;
|
||||||
|
// check for SSL redirect
|
||||||
|
if ($row_ipsandports['ssl'] == '0' && Settings::Get('system.le_froxlor_redirect') == '1') {
|
||||||
|
$is_redirect = true;
|
||||||
|
// check whether froxlor uses Let's Encrypt and not cert is being generated yet
|
||||||
|
// or a renew is ongoing - disable redirect
|
||||||
|
if (System::Get('system.le_froxlor_enabled') && ($this->froxlorVhostHasLetsEncryptCert() == false || $this->froxlorVhostLetsEncryptNeedsRenew())) {
|
||||||
|
$this->virtualhosts_data[$vhosts_filename] .= '# temp. disabled ssl-redirect due to Let\'s Encrypt certificate generation.' . PHP_EOL;
|
||||||
|
$is_redirect = false;
|
||||||
|
} else {
|
||||||
|
$_sslport = $this->checkAlternativeSslPort();
|
||||||
|
|
||||||
|
$mypath = 'https://' . Settings::Get('system.hostname') . $_sslport . '/';
|
||||||
|
$code = '301';
|
||||||
|
$modrew_red = ' [R=' . $code . ';L,NE]';
|
||||||
|
|
||||||
|
// redirect everything, not only root-directory, #541
|
||||||
|
$this->virtualhosts_data[$vhosts_filename] .= ' <IfModule mod_rewrite.c>' . "\n";
|
||||||
|
$this->virtualhosts_data[$vhosts_filename] .= ' RewriteEngine On' . "\n";
|
||||||
|
$this->virtualhosts_data[$vhosts_filename] .= ' RewriteCond %{HTTPS} off' . "\n";
|
||||||
|
if (System::Get('system.le_froxlor_enabled') == '1') {
|
||||||
|
$this->virtualhosts_data[$vhosts_filename] .= ' RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge' . "\n";
|
||||||
|
}
|
||||||
|
$this->virtualhosts_data[$vhosts_filename] .= ' RewriteRule ^/(.*) ' . $mypath . '$1' . $modrew_red . "\n";
|
||||||
|
$this->virtualhosts_data[$vhosts_filename] .= ' </IfModule>' . "\n";
|
||||||
|
$this->virtualhosts_data[$vhosts_filename] .= ' <IfModule !mod_rewrite.c>' . "\n";
|
||||||
|
$this->virtualhosts_data[$vhosts_filename] .= ' Redirect ' . $code . ' / ' . $mypath . "\n";
|
||||||
|
$this->virtualhosts_data[$vhosts_filename] .= ' </IfModule>' . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$is_redirect) {
|
||||||
// create fcgid <Directory>-Part (starter is created in apache_fcgid)
|
// create fcgid <Directory>-Part (starter is created in apache_fcgid)
|
||||||
if (Settings::Get('system.mod_fcgid_ownvhost') == '1'
|
if (Settings::Get('system.mod_fcgid_ownvhost') == '1' && Settings::Get('system.mod_fcgid') == '1') {
|
||||||
&& Settings::Get('system.mod_fcgid') == '1'
|
|
||||||
) {
|
|
||||||
$configdir = makeCorrectDir(Settings::Get('system.mod_fcgid_configdir') . '/froxlor.panel/' . Settings::Get('system.hostname'));
|
$configdir = makeCorrectDir(Settings::Get('system.mod_fcgid_configdir') . '/froxlor.panel/' . Settings::Get('system.hostname'));
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= ' FcgidIdleTimeout ' . Settings::Get('system.mod_fcgid_idle_timeout') . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' FcgidIdleTimeout ' . Settings::Get('system.mod_fcgid_idle_timeout') . "\n";
|
||||||
if ((int) Settings::Get('system.mod_fcgid_wrapper') == 0) {
|
if ((int) Settings::Get('system.mod_fcgid_wrapper') == 0) {
|
||||||
@@ -249,8 +274,7 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= ' </Directory>' . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' </Directory>' . "\n";
|
||||||
}
|
}
|
||||||
}
|
} // create php-fpm <Directory>-Part (config is created in apache_fcgid)
|
||||||
// create php-fpm <Directory>-Part (config is created in apache_fcgid)
|
|
||||||
elseif (Settings::Get('phpfpm.enabled') == '1') {
|
elseif (Settings::Get('phpfpm.enabled') == '1') {
|
||||||
$domain = array(
|
$domain = array(
|
||||||
'id' => 'none',
|
'id' => 'none',
|
||||||
@@ -262,7 +286,7 @@ class apache extends HttpConfigBase {
|
|||||||
'openbasedir' => 0,
|
'openbasedir' => 0,
|
||||||
'email' => Settings::Get('panel.adminmail'),
|
'email' => Settings::Get('panel.adminmail'),
|
||||||
'loginname' => 'froxlor.panel',
|
'loginname' => 'froxlor.panel',
|
||||||
'documentroot' => $mypath,
|
'documentroot' => $mypath
|
||||||
);
|
);
|
||||||
|
|
||||||
$php = new phpinterface($domain);
|
$php = new phpinterface($domain);
|
||||||
@@ -273,13 +297,10 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mod_proxy stuff for apache-2.4
|
// mod_proxy stuff for apache-2.4
|
||||||
if (Settings::Get('system.apache24') == '1'
|
if (Settings::Get('system.apache24') == '1' && Settings::Get('phpfpm.use_mod_proxy') == '1') {
|
||||||
&& Settings::Get('phpfpm.use_mod_proxy') == '1'
|
|
||||||
) {
|
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= ' <FilesMatch \.php$>' . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' <FilesMatch \.php$>' . "\n";
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= ' SetHandler proxy:unix:' . $php->getInterface()->getSocketFile() . '|fcgi://localhost' . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' SetHandler proxy:unix:' . $php->getInterface()->getSocketFile() . '|fcgi://localhost' . "\n";
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= ' </FilesMatch>' . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' </FilesMatch>' . "\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . $srvName . ' -socket ' . $php->getInterface()->getSocketFile() . ' -idle-timeout ' . Settings::Get('phpfpm.idle_timeout') . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' FastCgiExternalServer ' . $php->getInterface()->getAliasConfigDir() . $srvName . ' -socket ' . $php->getInterface()->getSocketFile() . ' -idle-timeout ' . Settings::Get('phpfpm.idle_timeout') . "\n";
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= ' <Directory "' . $mypath . '">' . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' <Directory "' . $mypath . '">' . "\n";
|
||||||
@@ -305,9 +326,7 @@ class apache extends HttpConfigBase {
|
|||||||
$this->virtualhosts_data[$vhosts_filename] .= ' </Directory>' . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' </Directory>' . "\n";
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= ' Alias /fastcgiphp ' . $php->getInterface()->getAliasConfigDir() . $srvName . "\n";
|
$this->virtualhosts_data[$vhosts_filename] .= ' Alias /fastcgiphp ' . $php->getInterface()->getAliasConfigDir() . $srvName . "\n";
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// mod_php
|
// mod_php
|
||||||
$domain = array(
|
$domain = array(
|
||||||
'id' => 'none',
|
'id' => 'none',
|
||||||
@@ -320,29 +339,26 @@ class apache extends HttpConfigBase {
|
|||||||
'documentroot' => $mypath
|
'documentroot' => $mypath
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} // end of ssl-redirect check
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dirprotection, see #72
|
* dirprotection, see #72
|
||||||
* @TODO deferred until 0.9.5, needs more testing
|
*
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= "\t<Directory \"'.$mypath.'(images|packages|templates)\">\n";
|
* @todo deferred until 0.9.5, needs more testing
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= "\t\tAllow from all\n";
|
* $this->virtualhosts_data[$vhosts_filename] .= "\t<Directory \"'.$mypath.'(images|packages|templates)\">\n";
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= "\t\tOptions -Indexes\n";
|
* $this->virtualhosts_data[$vhosts_filename] .= "\t\tAllow from all\n";
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= "\t</Directory>\n";
|
* $this->virtualhosts_data[$vhosts_filename] .= "\t\tOptions -Indexes\n";
|
||||||
|
* $this->virtualhosts_data[$vhosts_filename] .= "\t</Directory>\n";
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= "\t<Directory \"'.$mypath.'*\">\n";
|
*
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= "\t\tOrder Deny,Allow\n";
|
* $this->virtualhosts_data[$vhosts_filename] .= "\t<Directory \"'.$mypath.'*\">\n";
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= "\t\tDeny from All\n";
|
* $this->virtualhosts_data[$vhosts_filename] .= "\t\tOrder Deny,Allow\n";
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= "\t</Directory>\n";
|
* $this->virtualhosts_data[$vhosts_filename] .= "\t\tDeny from All\n";
|
||||||
|
* $this->virtualhosts_data[$vhosts_filename] .= "\t</Directory>\n";
|
||||||
* end of dirprotection
|
* end of dirprotection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($row_ipsandports['specialsettings'] != '') {
|
if ($row_ipsandports['specialsettings'] != '') {
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= $this->processSpecialConfigTemplate(
|
$this->virtualhosts_data[$vhosts_filename] .= $this->processSpecialConfigTemplate($row_ipsandports['specialsettings'], $domain, $row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'] == '1') . "\n";
|
||||||
$row_ipsandports['specialsettings'],
|
|
||||||
$domain,
|
|
||||||
$row_ipsandports['ip'],
|
|
||||||
$row_ipsandports['port'],
|
|
||||||
$row_ipsandports['ssl'] == '1') . "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($row_ipsandports['ssl'] == '1' && Settings::Get('system.use_ssl') == '1') {
|
if ($row_ipsandports['ssl'] == '1' && Settings::Get('system.use_ssl') == '1') {
|
||||||
@@ -369,7 +385,7 @@ class apache extends HttpConfigBase {
|
|||||||
'adminid' => 1, /* first admin-user (superadmin) */
|
'adminid' => 1, /* first admin-user (superadmin) */
|
||||||
'loginname' => 'froxlor.panel',
|
'loginname' => 'froxlor.panel',
|
||||||
'documentroot' => $mypath,
|
'documentroot' => $mypath,
|
||||||
'parentdomainid' => 0,
|
'parentdomainid' => 0
|
||||||
);
|
);
|
||||||
|
|
||||||
// override corresponding array values
|
// override corresponding array values
|
||||||
@@ -451,7 +467,6 @@ class apache extends HttpConfigBase {
|
|||||||
$this->_createStandardErrorHandler();
|
$this->_createStandardErrorHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We put together the needed php options in the virtualhost entries
|
* We put together the needed php options in the virtualhost entries
|
||||||
*
|
*
|
||||||
@@ -460,20 +475,17 @@ class apache extends HttpConfigBase {
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function composePhpOptions($domain, $ssl_vhost = false) {
|
protected function composePhpOptions($domain, $ssl_vhost = false)
|
||||||
|
{
|
||||||
$php_options_text = '';
|
$php_options_text = '';
|
||||||
|
|
||||||
if ($domain['phpenabled'] == '1') {
|
if ($domain['phpenabled'] == '1') {
|
||||||
// This vHost has PHP enabled and we are using the regular mod_php
|
// This vHost has PHP enabled and we are using the regular mod_php
|
||||||
|
|
||||||
if ($domain['openbasedir'] == '1')
|
if ($domain['openbasedir'] == '1') {
|
||||||
{
|
if ($domain['openbasedir_path'] == '1' || strstr($domain['documentroot'], ":") !== false) {
|
||||||
if ($domain['openbasedir_path'] == '1' || strstr($domain['documentroot'], ":") !== false)
|
|
||||||
{
|
|
||||||
$_phpappendopenbasedir = appendOpenBasedirPath($domain['customerroot'], true);
|
$_phpappendopenbasedir = appendOpenBasedirPath($domain['customerroot'], true);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$_phpappendopenbasedir = appendOpenBasedirPath($domain['documentroot'], true);
|
$_phpappendopenbasedir = appendOpenBasedirPath($domain['documentroot'], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,14 +514,14 @@ class apache extends HttpConfigBase {
|
|||||||
return $php_options_text;
|
return $php_options_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createOwnVhostStarter()
|
||||||
public function createOwnVhostStarter() {}
|
{}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We collect all servernames and Aliases
|
* We collect all servernames and Aliases
|
||||||
*/
|
*/
|
||||||
protected function getServerNames($domain) {
|
protected function getServerNames($domain)
|
||||||
|
{
|
||||||
$servernames_text = ' ServerName ' . $domain['domain'] . "\n";
|
$servernames_text = ' ServerName ' . $domain['domain'] . "\n";
|
||||||
|
|
||||||
$server_alias = '';
|
$server_alias = '';
|
||||||
@@ -528,7 +540,9 @@ class apache extends HttpConfigBase {
|
|||||||
FROM `" . TABLE_PANEL_DOMAINS . "`
|
FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||||
WHERE `aliasdomain`= :domainid
|
WHERE `aliasdomain`= :domainid
|
||||||
");
|
");
|
||||||
Database::pexecute($alias_domains_stmt, array('domainid' => $domain['id']));
|
Database::pexecute($alias_domains_stmt, array(
|
||||||
|
'domainid' => $domain['id']
|
||||||
|
));
|
||||||
|
|
||||||
while (($alias_domain = $alias_domains_stmt->fetch(PDO::FETCH_ASSOC)) !== false) {
|
while (($alias_domain = $alias_domains_stmt->fetch(PDO::FETCH_ASSOC)) !== false) {
|
||||||
$server_alias = ' ServerAlias ' . $alias_domain['domain'];
|
$server_alias = ' ServerAlias ' . $alias_domain['domain'];
|
||||||
@@ -548,18 +562,16 @@ class apache extends HttpConfigBase {
|
|||||||
return $servernames_text;
|
return $servernames_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Let's get the webroot
|
* Let's get the webroot
|
||||||
*/
|
*/
|
||||||
protected function getWebroot($domain) {
|
protected function getWebroot($domain)
|
||||||
|
{
|
||||||
$webroot_text = '';
|
$webroot_text = '';
|
||||||
$domain['customerroot'] = makeCorrectDir($domain['customerroot']);
|
$domain['customerroot'] = makeCorrectDir($domain['customerroot']);
|
||||||
$domain['documentroot'] = makeCorrectDir($domain['documentroot']);
|
$domain['documentroot'] = makeCorrectDir($domain['documentroot']);
|
||||||
|
|
||||||
if ($domain['deactivated'] == '1'
|
if ($domain['deactivated'] == '1' && Settings::Get('system.deactivateddocroot') != '') {
|
||||||
&& Settings::Get('system.deactivateddocroot') != ''
|
|
||||||
) {
|
|
||||||
$webroot_text .= ' # Using docroot for deactivated users...' . "\n";
|
$webroot_text .= ' # Using docroot for deactivated users...' . "\n";
|
||||||
$webroot_text .= ' DocumentRoot "' . makeCorrectDir(Settings::Get('system.deactivateddocroot')) . "\"\n";
|
$webroot_text .= ' DocumentRoot "' . makeCorrectDir(Settings::Get('system.deactivateddocroot')) . "\"\n";
|
||||||
$this->_deactivated = true;
|
$this->_deactivated = true;
|
||||||
@@ -571,11 +583,11 @@ class apache extends HttpConfigBase {
|
|||||||
return $webroot_text;
|
return $webroot_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lets set the text part for the stats software
|
* Lets set the text part for the stats software
|
||||||
*/
|
*/
|
||||||
protected function getStats($domain) {
|
protected function getStats($domain)
|
||||||
|
{
|
||||||
$stats_text = '';
|
$stats_text = '';
|
||||||
|
|
||||||
if ($domain['speciallogfile'] == '1') {
|
if ($domain['speciallogfile'] == '1') {
|
||||||
@@ -594,8 +606,7 @@ class apache extends HttpConfigBase {
|
|||||||
} else {
|
} else {
|
||||||
$stats_text .= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer') . '"' . "\n";
|
$stats_text .= ' Alias /webalizer "' . makeCorrectFile($domain['customerroot'] . '/webalizer') . '"' . "\n";
|
||||||
}
|
}
|
||||||
}
|
} // if the docroots are equal, we still have to set an alias for awstats
|
||||||
// if the docroots are equal, we still have to set an alias for awstats
|
|
||||||
// because the stats are in /awstats/[domain], not just /awstats/
|
// because the stats are in /awstats/[domain], not just /awstats/
|
||||||
// also, the awstats-icons are someplace else too!
|
// also, the awstats-icons are someplace else too!
|
||||||
// -> webalizer does not need this!
|
// -> webalizer does not need this!
|
||||||
@@ -608,12 +619,11 @@ class apache extends HttpConfigBase {
|
|||||||
return $stats_text;
|
return $stats_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lets set the logfiles
|
* Lets set the logfiles
|
||||||
*/
|
*/
|
||||||
protected function getLogfiles($domain) {
|
protected function getLogfiles($domain)
|
||||||
|
{
|
||||||
$logfiles_text = '';
|
$logfiles_text = '';
|
||||||
|
|
||||||
if ($domain['speciallogfile'] == '1') {
|
if ($domain['speciallogfile'] == '1') {
|
||||||
@@ -651,7 +661,9 @@ class apache extends HttpConfigBase {
|
|||||||
FROM `" . TABLE_PANEL_DOMAINS . "`
|
FROM `" . TABLE_PANEL_DOMAINS . "`
|
||||||
WHERE `aliasdomain` = :domainid OR `parentdomainid` = :domainid
|
WHERE `aliasdomain` = :domainid OR `parentdomainid` = :domainid
|
||||||
");
|
");
|
||||||
Database::pexecute($alias_domains_stmt, array('domainid' => $domain['id']));
|
Database::pexecute($alias_domains_stmt, array(
|
||||||
|
'domainid' => $domain['id']
|
||||||
|
));
|
||||||
|
|
||||||
while (($alias_domain = $alias_domains_stmt->fetch(PDO::FETCH_ASSOC)) !== false) {
|
while (($alias_domain = $alias_domains_stmt->fetch(PDO::FETCH_ASSOC)) !== false) {
|
||||||
|
|
||||||
@@ -682,21 +694,14 @@ class apache extends HttpConfigBase {
|
|||||||
return $logfiles_text;
|
return $logfiles_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the filename for the virtualhost
|
* Get the filename for the virtualhost
|
||||||
*/
|
*/
|
||||||
protected function getVhostFilename($domain, $ssl_vhost = false) {
|
protected function getVhostFilename($domain, $ssl_vhost = false)
|
||||||
if ((int)$domain['parentdomainid'] == 0
|
{
|
||||||
&& isCustomerStdSubdomain((int)$domain['id']) == false
|
if ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && ((int) $domain['ismainbutsubto'] == 0 || domainMainToSubExists($domain['ismainbutsubto']) == false)) {
|
||||||
&& ((int)$domain['ismainbutsubto'] == 0
|
|
||||||
|| domainMainToSubExists($domain['ismainbutsubto']) == false)
|
|
||||||
) {
|
|
||||||
$vhost_no = '35';
|
$vhost_no = '35';
|
||||||
} elseif ((int)$domain['parentdomainid'] == 0
|
} elseif ((int) $domain['parentdomainid'] == 0 && isCustomerStdSubdomain((int) $domain['id']) == false && (int) $domain['ismainbutsubto'] > 0) {
|
||||||
&& isCustomerStdSubdomain((int)$domain['id']) == false
|
|
||||||
&& (int)$domain['ismainbutsubto'] > 0
|
|
||||||
) {
|
|
||||||
$vhost_no = '30';
|
$vhost_no = '30';
|
||||||
} else {
|
} else {
|
||||||
// number of dots in a domain specifies it's position (and depth of subdomain) starting at 29 going downwards on higher depth
|
// number of dots in a domain specifies it's position (and depth of subdomain) starting at 29 going downwards on higher depth
|
||||||
@@ -715,20 +720,16 @@ class apache extends HttpConfigBase {
|
|||||||
/**
|
/**
|
||||||
* We compose the virtualhost entry for one domain
|
* We compose the virtualhost entry for one domain
|
||||||
*/
|
*/
|
||||||
protected function getVhostContent($domain, $ssl_vhost = false) {
|
protected function getVhostContent($domain, $ssl_vhost = false)
|
||||||
if ($ssl_vhost === true
|
{
|
||||||
&& ($domain['ssl_redirect'] != '1'
|
if ($ssl_vhost === true && ($domain['ssl_redirect'] != '1' && $domain['ssl'] != '1')) {
|
||||||
&& $domain['ssl'] != '1')
|
|
||||||
) {
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = "SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` `i`, `" . TABLE_DOMAINTOIP . "` `dip`
|
$query = "SELECT * FROM `" . TABLE_PANEL_IPSANDPORTS . "` `i`, `" . TABLE_DOMAINTOIP . "` `dip`
|
||||||
WHERE dip.id_domain = :domainid AND i.id = dip.id_ipandports ";
|
WHERE dip.id_domain = :domainid AND i.id = dip.id_ipandports ";
|
||||||
|
|
||||||
if ($ssl_vhost === true
|
if ($ssl_vhost === true && ($domain['ssl'] == '1' || $domain['ssl_redirect'] == '1')) {
|
||||||
&& ($domain['ssl'] == '1' || $domain['ssl_redirect'] == '1')
|
|
||||||
) {
|
|
||||||
// by ordering by cert-file the row with filled out SSL-Fields will be shown last, thus it is enough to fill out 1 set of SSL-Fields
|
// by ordering by cert-file the row with filled out SSL-Fields will be shown last, thus it is enough to fill out 1 set of SSL-Fields
|
||||||
$query .= "AND i.ssl = '1' ORDER BY i.ssl_cert_file ASC;";
|
$query .= "AND i.ssl = '1' ORDER BY i.ssl_cert_file ASC;";
|
||||||
} else {
|
} else {
|
||||||
@@ -737,7 +738,9 @@ class apache extends HttpConfigBase {
|
|||||||
|
|
||||||
$vhost_content = '';
|
$vhost_content = '';
|
||||||
$result_stmt = Database::prepare($query);
|
$result_stmt = Database::prepare($query);
|
||||||
Database::pexecute($result_stmt, array('domainid' => $domain['id']));
|
Database::pexecute($result_stmt, array(
|
||||||
|
'domainid' => $domain['id']
|
||||||
|
));
|
||||||
|
|
||||||
$ipportlist = '';
|
$ipportlist = '';
|
||||||
$_vhost_content = '';
|
$_vhost_content = '';
|
||||||
@@ -766,12 +769,7 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($ipandport['default_vhostconf_domain'] != '') {
|
if ($ipandport['default_vhostconf_domain'] != '') {
|
||||||
$_vhost_content .= $this->processSpecialConfigTemplate(
|
$_vhost_content .= $this->processSpecialConfigTemplate($ipandport['default_vhostconf_domain'], $domain, $domain['ip'], $domain['port'], $ssl_vhost) . "\n";
|
||||||
$ipandport['default_vhostconf_domain'],
|
|
||||||
$domain,
|
|
||||||
$domain['ip'],
|
|
||||||
$domain['port'],
|
|
||||||
$ssl_vhost) . "\n";
|
|
||||||
}
|
}
|
||||||
$ipportlist .= $ipport;
|
$ipportlist .= $ipport;
|
||||||
}
|
}
|
||||||
@@ -779,10 +777,7 @@ class apache extends HttpConfigBase {
|
|||||||
$vhost_content .= '<VirtualHost ' . trim($ipportlist) . '>' . "\n";
|
$vhost_content .= '<VirtualHost ' . trim($ipportlist) . '>' . "\n";
|
||||||
$vhost_content .= $this->getServerNames($domain);
|
$vhost_content .= $this->getServerNames($domain);
|
||||||
|
|
||||||
if (($ssl_vhost == false
|
if (($ssl_vhost == false && $domain['ssl'] == '1' && $domain['ssl_redirect'] == '1')) {
|
||||||
&& $domain['ssl'] == '1'
|
|
||||||
&& $domain['ssl_redirect'] == '1')
|
|
||||||
) {
|
|
||||||
// We must not check if our port differs from port 443,
|
// We must not check if our port differs from port 443,
|
||||||
// but if there is a destination-port != 443
|
// but if there is a destination-port != 443
|
||||||
$_sslport = '';
|
$_sslport = '';
|
||||||
@@ -796,7 +791,9 @@ class apache extends HttpConfigBase {
|
|||||||
AND `ip`.`ssl` = '1' AND `ip`.`port` != 443
|
AND `ip`.`ssl` = '1' AND `ip`.`port` != 443
|
||||||
ORDER BY `ip`.`ssl_cert_file` DESC, `ip`.`port` LIMIT 1;
|
ORDER BY `ip`.`ssl_cert_file` DESC, `ip`.`port` LIMIT 1;
|
||||||
");
|
");
|
||||||
$ssldestport = Database::pexecute_first($ssldestport_stmt, array('domainid' => $domain['id']));
|
$ssldestport = Database::pexecute_first($ssldestport_stmt, array(
|
||||||
|
'domainid' => $domain['id']
|
||||||
|
));
|
||||||
|
|
||||||
if ($ssldestport['port'] != '') {
|
if ($ssldestport['port'] != '') {
|
||||||
$_sslport = ":" . $ssldestport['port'];
|
$_sslport = ":" . $ssldestport['port'];
|
||||||
@@ -805,10 +802,7 @@ class apache extends HttpConfigBase {
|
|||||||
$domain['documentroot'] = 'https://' . $domain['domain'] . $_sslport . '/';
|
$domain['documentroot'] = 'https://' . $domain['domain'] . $_sslport . '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ssl_vhost === true
|
if ($ssl_vhost === true && $domain['ssl'] == '1' && Settings::Get('system.use_ssl') == '1') {
|
||||||
&& $domain['ssl'] == '1'
|
|
||||||
&& Settings::Get('system.use_ssl') == '1'
|
|
||||||
) {
|
|
||||||
if ($domain['ssl_cert_file'] == '') {
|
if ($domain['ssl_cert_file'] == '') {
|
||||||
$domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
|
$domain['ssl_cert_file'] = Settings::Get('system.ssl_cert_file');
|
||||||
}
|
}
|
||||||
@@ -893,7 +887,6 @@ class apache extends HttpConfigBase {
|
|||||||
$vhost_content .= ' <IfModule !mod_rewrite.c>' . "\n";
|
$vhost_content .= ' <IfModule !mod_rewrite.c>' . "\n";
|
||||||
$vhost_content .= ' Redirect ' . $code . ' / ' . $this->idnaConvert->encode($domain['documentroot']) . "\n";
|
$vhost_content .= ' Redirect ' . $code . ' / ' . $this->idnaConvert->encode($domain['documentroot']) . "\n";
|
||||||
$vhost_content .= ' </IfModule>' . "\n";
|
$vhost_content .= ' </IfModule>' . "\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
|
mkDirWithCorrectOwnership($domain['customerroot'], $domain['documentroot'], $domain['guid'], $domain['guid'], true, true);
|
||||||
@@ -905,12 +898,7 @@ class apache extends HttpConfigBase {
|
|||||||
$vhost_content .= $this->getLogfiles($domain);
|
$vhost_content .= $this->getLogfiles($domain);
|
||||||
|
|
||||||
if ($domain['specialsettings'] != '') {
|
if ($domain['specialsettings'] != '') {
|
||||||
$vhost_content .= $this->processSpecialConfigTemplate(
|
$vhost_content .= $this->processSpecialConfigTemplate($domain['specialsettings'], $domain, $domain['ip'], $domain['port'], $ssl_vhost) . "\n";
|
||||||
$domain['specialsettings'],
|
|
||||||
$domain,
|
|
||||||
$domain['ip'],
|
|
||||||
$domain['port'],
|
|
||||||
$ssl_vhost) . "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_vhost_content != '') {
|
if ($_vhost_content != '') {
|
||||||
@@ -918,12 +906,7 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Settings::Get('system.default_vhostconf') != '') {
|
if (Settings::Get('system.default_vhostconf') != '') {
|
||||||
$vhost_content .= $this->processSpecialConfigTemplate(
|
$vhost_content .= $this->processSpecialConfigTemplate(Settings::Get('system.default_vhostconf'), $domain, $domain['ip'], $domain['port'], $ssl_vhost) . "\n";
|
||||||
Settings::Get('system.default_vhostconf'),
|
|
||||||
$domain,
|
|
||||||
$domain['ip'],
|
|
||||||
$domain['port'],
|
|
||||||
$ssl_vhost) . "\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -932,12 +915,11 @@ class apache extends HttpConfigBase {
|
|||||||
return $vhost_content;
|
return $vhost_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We compose the virtualhost entries for the domains
|
* We compose the virtualhost entries for the domains
|
||||||
*/
|
*/
|
||||||
public function createVirtualHosts() {
|
public function createVirtualHosts()
|
||||||
|
{
|
||||||
$domains = WebserverBase::getVhostsToCreate();
|
$domains = WebserverBase::getVhostsToCreate();
|
||||||
foreach ($domains as $domain) {
|
foreach ($domains as $domain) {
|
||||||
|
|
||||||
@@ -947,9 +929,7 @@ class apache extends HttpConfigBase {
|
|||||||
// Apply header
|
// Apply header
|
||||||
$this->virtualhosts_data[$vhosts_filename] = '# Domain ID: ' . $domain['id'] . ' - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: ' . $domain['loginname'] . "\n";
|
$this->virtualhosts_data[$vhosts_filename] = '# Domain ID: ' . $domain['id'] . ' - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: ' . $domain['loginname'] . "\n";
|
||||||
|
|
||||||
if ($domain['deactivated'] != '1'
|
if ($domain['deactivated'] != '1' || Settings::Get('system.deactivateddocroot') != '') {
|
||||||
|| Settings::Get('system.deactivateddocroot') != ''
|
|
||||||
) {
|
|
||||||
// Create vhost without ssl
|
// Create vhost without ssl
|
||||||
$this->virtualhosts_data[$vhosts_filename] .= $this->getVhostContent($domain, false);
|
$this->virtualhosts_data[$vhosts_filename] .= $this->getVhostContent($domain, false);
|
||||||
|
|
||||||
@@ -965,11 +945,11 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We compose the diroption entries for the paths
|
* We compose the diroption entries for the paths
|
||||||
*/
|
*/
|
||||||
public function createFileDirOptions() {
|
public function createFileDirOptions()
|
||||||
|
{
|
||||||
$result_stmt = Database::query("
|
$result_stmt = Database::query("
|
||||||
SELECT `htac`.*, `c`.`guid`, `c`.`documentroot` AS `customerroot`
|
SELECT `htac`.*, `c`.`guid`, `c`.`documentroot` AS `customerroot`
|
||||||
FROM `" . TABLE_PANEL_HTACCESS . "` `htac`
|
FROM `" . TABLE_PANEL_HTACCESS . "` `htac`
|
||||||
@@ -979,10 +959,7 @@ class apache extends HttpConfigBase {
|
|||||||
$diroptions = array();
|
$diroptions = array();
|
||||||
|
|
||||||
while ($row_diroptions = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row_diroptions = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
if ($row_diroptions['customerid'] != 0
|
if ($row_diroptions['customerid'] != 0 && isset($row_diroptions['customerroot']) && $row_diroptions['customerroot'] != '') {
|
||||||
&& isset($row_diroptions['customerroot'])
|
|
||||||
&& $row_diroptions['customerroot'] != ''
|
|
||||||
) {
|
|
||||||
$diroptions[$row_diroptions['path']] = $row_diroptions;
|
$diroptions[$row_diroptions['path']] = $row_diroptions;
|
||||||
$diroptions[$row_diroptions['path']]['htpasswds'] = array();
|
$diroptions[$row_diroptions['path']]['htpasswds'] = array();
|
||||||
}
|
}
|
||||||
@@ -996,10 +973,7 @@ class apache extends HttpConfigBase {
|
|||||||
");
|
");
|
||||||
|
|
||||||
while ($row_htpasswds = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row_htpasswds = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
if ($row_htpasswds['customerid'] != 0
|
if ($row_htpasswds['customerid'] != 0 && isset($row_htpasswds['customerroot']) && $row_htpasswds['customerroot'] != '') {
|
||||||
&& isset($row_htpasswds['customerroot'])
|
|
||||||
&& $row_htpasswds['customerroot'] != ''
|
|
||||||
) {
|
|
||||||
if (! isset($diroptions[$row_htpasswds['path']]) || ! is_array($diroptions[$row_htpasswds['path']])) {
|
if (! isset($diroptions[$row_htpasswds['path']]) || ! is_array($diroptions[$row_htpasswds['path']])) {
|
||||||
$diroptions[$row_htpasswds['path']] = array();
|
$diroptions[$row_htpasswds['path']] = array();
|
||||||
}
|
}
|
||||||
@@ -1026,16 +1000,11 @@ class apache extends HttpConfigBase {
|
|||||||
|
|
||||||
$this->diroptions_data[$diroptions_filename] .= '<Directory "' . $row_diroptions['path'] . '">' . "\n";
|
$this->diroptions_data[$diroptions_filename] .= '<Directory "' . $row_diroptions['path'] . '">' . "\n";
|
||||||
|
|
||||||
if (isset($row_diroptions['options_indexes'])
|
if (isset($row_diroptions['options_indexes']) && $row_diroptions['options_indexes'] == '1') {
|
||||||
&& $row_diroptions['options_indexes'] == '1'
|
|
||||||
) {
|
|
||||||
$this->diroptions_data[$diroptions_filename] .= ' Options +Indexes';
|
$this->diroptions_data[$diroptions_filename] .= ' Options +Indexes';
|
||||||
|
|
||||||
// add perl options if enabled
|
// add perl options if enabled
|
||||||
if ($cperlenabled
|
if ($cperlenabled && isset($row_diroptions['options_cgi']) && $row_diroptions['options_cgi'] == '1') {
|
||||||
&& isset($row_diroptions['options_cgi'])
|
|
||||||
&& $row_diroptions['options_cgi'] == '1'
|
|
||||||
) {
|
|
||||||
$this->diroptions_data[$diroptions_filename] .= ' +ExecCGI -MultiViews +SymLinksIfOwnerMatch +FollowSymLinks' . "\n";
|
$this->diroptions_data[$diroptions_filename] .= ' +ExecCGI -MultiViews +SymLinksIfOwnerMatch +FollowSymLinks' . "\n";
|
||||||
} else {
|
} else {
|
||||||
$this->diroptions_data[$diroptions_filename] .= "\n";
|
$this->diroptions_data[$diroptions_filename] .= "\n";
|
||||||
@@ -1043,16 +1012,11 @@ class apache extends HttpConfigBase {
|
|||||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Setting Options +Indexes for ' . $row_diroptions['path']);
|
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Setting Options +Indexes for ' . $row_diroptions['path']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($row_diroptions['options_indexes'])
|
if (isset($row_diroptions['options_indexes']) && $row_diroptions['options_indexes'] == '0') {
|
||||||
&& $row_diroptions['options_indexes'] == '0'
|
|
||||||
) {
|
|
||||||
$this->diroptions_data[$diroptions_filename] .= ' Options -Indexes';
|
$this->diroptions_data[$diroptions_filename] .= ' Options -Indexes';
|
||||||
|
|
||||||
// add perl options if enabled
|
// add perl options if enabled
|
||||||
if ($cperlenabled
|
if ($cperlenabled && isset($row_diroptions['options_cgi']) && $row_diroptions['options_cgi'] == '1') {
|
||||||
&& isset($row_diroptions['options_cgi'])
|
|
||||||
&& $row_diroptions['options_cgi'] == '1'
|
|
||||||
) {
|
|
||||||
$this->diroptions_data[$diroptions_filename] .= ' +ExecCGI -MultiViews +SymLinksIfOwnerMatch +FollowSymLinks' . "\n";
|
$this->diroptions_data[$diroptions_filename] .= ' +ExecCGI -MultiViews +SymLinksIfOwnerMatch +FollowSymLinks' . "\n";
|
||||||
} else {
|
} else {
|
||||||
$this->diroptions_data[$diroptions_filename] .= "\n";
|
$this->diroptions_data[$diroptions_filename] .= "\n";
|
||||||
@@ -1060,11 +1024,13 @@ class apache extends HttpConfigBase {
|
|||||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Setting Options -Indexes for ' . $row_diroptions['path']);
|
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Setting Options -Indexes for ' . $row_diroptions['path']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$statusCodes = array('404', '403', '500');
|
$statusCodes = array(
|
||||||
|
'404',
|
||||||
|
'403',
|
||||||
|
'500'
|
||||||
|
);
|
||||||
foreach ($statusCodes as $statusCode) {
|
foreach ($statusCodes as $statusCode) {
|
||||||
if (isset($row_diroptions['error' . $statusCode . 'path'])
|
if (isset($row_diroptions['error' . $statusCode . 'path']) && $row_diroptions['error' . $statusCode . 'path'] != '') {
|
||||||
&& $row_diroptions['error' . $statusCode . 'path'] != ''
|
|
||||||
) {
|
|
||||||
$defhandler = $row_diroptions['error' . $statusCode . 'path'];
|
$defhandler = $row_diroptions['error' . $statusCode . 'path'];
|
||||||
if (! validateUrl($defhandler)) {
|
if (! validateUrl($defhandler)) {
|
||||||
if (substr($defhandler, 0, 1) != '"' && substr($defhandler, - 1, 1) != '"') {
|
if (substr($defhandler, 0, 1) != '"' && substr($defhandler, - 1, 1) != '"') {
|
||||||
@@ -1075,10 +1041,7 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cperlenabled
|
if ($cperlenabled && isset($row_diroptions['options_cgi']) && $row_diroptions['options_cgi'] == '1') {
|
||||||
&& isset($row_diroptions['options_cgi'])
|
|
||||||
&& $row_diroptions['options_cgi'] == '1'
|
|
||||||
) {
|
|
||||||
$this->diroptions_data[$diroptions_filename] .= ' AllowOverride None' . "\n";
|
$this->diroptions_data[$diroptions_filename] .= ' AllowOverride None' . "\n";
|
||||||
$this->diroptions_data[$diroptions_filename] .= ' AddHandler cgi-script .cgi .pl' . "\n";
|
$this->diroptions_data[$diroptions_filename] .= ' AddHandler cgi-script .cgi .pl' . "\n";
|
||||||
// >=apache-2.4 enabled?
|
// >=apache-2.4 enabled?
|
||||||
@@ -1156,11 +1119,11 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We write the configs
|
* We write the configs
|
||||||
*/
|
*/
|
||||||
public function writeConfigs() {
|
public function writeConfigs()
|
||||||
|
{
|
||||||
// Write diroptions
|
// Write diroptions
|
||||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_diroptions'));
|
$this->logger->logAction(CRON_ACTION, LOG_INFO, "apache::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_diroptions'));
|
||||||
|
|
||||||
@@ -1275,6 +1238,4 @@ class apache extends HttpConfigBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,19 +100,30 @@ class lighttpd extends HttpConfigBase
|
|||||||
$this->lighttpd_data[$vhost_filename] .= '# Froxlor default vhost' . "\n";
|
$this->lighttpd_data[$vhost_filename] .= '# Froxlor default vhost' . "\n";
|
||||||
$this->lighttpd_data[$vhost_filename] .= '$HTTP["host"] =~ "^(?:www\.|)' . $myhost . '$" {' . "\n";
|
$this->lighttpd_data[$vhost_filename] .= '$HTTP["host"] =~ "^(?:www\.|)' . $myhost . '$" {' . "\n";
|
||||||
|
|
||||||
if ($row_ipsandports['docroot'] == '') {
|
$mypath = $this->getMyPath($row_ipsandports);
|
||||||
if (Settings::Get('system.froxlordirectlyviahostname')) {
|
|
||||||
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
|
|
||||||
} else {
|
|
||||||
$mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// user-defined docroot, #417
|
|
||||||
$mypath = makeCorrectDir($row_ipsandports['docroot']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->lighttpd_data[$vhost_filename] .= ' server.document-root = "' . $mypath . '"' . "\n";
|
$this->lighttpd_data[$vhost_filename] .= ' server.document-root = "' . $mypath . '"' . "\n";
|
||||||
|
|
||||||
|
$is_redirect = false;
|
||||||
|
// check for SSL redirect
|
||||||
|
if ($row_ipsandports['ssl'] == '0' && Settings::Get('system.le_froxlor_redirect') == '1') {
|
||||||
|
$is_redirect = true;
|
||||||
|
// check whether froxlor uses Let's Encrypt and not cert is being generated yet
|
||||||
|
// or a renew is ongoing - disable redirect
|
||||||
|
if (System::Get('system.le_froxlor_enabled') && ($this->froxlorVhostHasLetsEncryptCert() == false || $this->froxlorVhostLetsEncryptNeedsRenew())) {
|
||||||
|
$this->lighttpd_data[$vhost_filename] .= '# temp. disabled ssl-redirect due to Let\'s Encrypt certificate generation.' . PHP_EOL;
|
||||||
|
$is_redirect = false;
|
||||||
|
} else {
|
||||||
|
$_sslport = $this->checkAlternativeSslPort();
|
||||||
|
$mypath = 'https://' . Settings::Get('system.hostname') . $_sslport . '/';
|
||||||
|
|
||||||
|
$this->lighttpd_data[$vhost_filename] .= ' url.redirect = (' . "\n";
|
||||||
|
$this->lighttpd_data[$vhost_filename] .= ' "^/(.*)$" => "' . $mypath . '$1"' . "\n";
|
||||||
|
$this->lighttpd_data[$vhost_filename] .= ' )' . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$is_redirect) {
|
||||||
/**
|
/**
|
||||||
* dirprotection, see #72
|
* dirprotection, see #72
|
||||||
*
|
*
|
||||||
@@ -152,6 +163,7 @@ class lighttpd extends HttpConfigBase
|
|||||||
$this->lighttpd_data[$vhost_filename] .= "\t" . ')' . "\n";
|
$this->lighttpd_data[$vhost_filename] .= "\t" . ')' . "\n";
|
||||||
$this->lighttpd_data[$vhost_filename] .= ' )' . "\n";
|
$this->lighttpd_data[$vhost_filename] .= ' )' . "\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($row_ipsandports['specialsettings'] != '') {
|
if ($row_ipsandports['specialsettings'] != '') {
|
||||||
$this->lighttpd_data[$vhost_filename] .= $this->processSpecialConfigTemplate($row_ipsandports['specialsettings'], $domain, $row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'] == '1') . "\n";
|
$this->lighttpd_data[$vhost_filename] .= $this->processSpecialConfigTemplate($row_ipsandports['specialsettings'], $domain, $row_ipsandports['ip'], $row_ipsandports['port'], $row_ipsandports['ssl'] == '1') . "\n";
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ class nginx extends HttpConfigBase {
|
|||||||
|
|
||||||
$this->nginx_data[$vhost_filename] .= 'server { ' . "\n";
|
$this->nginx_data[$vhost_filename] .= 'server { ' . "\n";
|
||||||
|
|
||||||
|
$mypath = $this->getMyPath($row_ipsandports);
|
||||||
|
|
||||||
// check for ssl before anything else so
|
// check for ssl before anything else so
|
||||||
// we know whether it's an ssl vhost or not
|
// we know whether it's an ssl vhost or not
|
||||||
$ssl_vhost = false;
|
$ssl_vhost = false;
|
||||||
@@ -191,26 +193,28 @@ class nginx extends HttpConfigBase {
|
|||||||
$this->nginx_data[$vhost_filename] .= "\t".'server_name ' . Settings::Get('system.hostname') . ';' . "\n";
|
$this->nginx_data[$vhost_filename] .= "\t".'server_name ' . Settings::Get('system.hostname') . ';' . "\n";
|
||||||
$this->nginx_data[$vhost_filename] .= "\t".'access_log /var/log/nginx/access.log;' . "\n";
|
$this->nginx_data[$vhost_filename] .= "\t".'access_log /var/log/nginx/access.log;' . "\n";
|
||||||
|
|
||||||
$mypath = '';
|
$is_redirect = false;
|
||||||
|
// check for SSL redirect
|
||||||
// no custom docroot set?
|
if ($row_ipsandports['ssl'] == '0' && Settings::Get('system.le_froxlor_redirect') == '1') {
|
||||||
if ($row_ipsandports['docroot'] == '') {
|
$is_redirect = true;
|
||||||
// check whether the hostname should directly point to
|
// check whether froxlor uses Let's Encrypt and not cert is being generated yet
|
||||||
// the froxlor-installation or not
|
// or a renew is ongoing - disable redirect
|
||||||
if (Settings::Get('system.froxlordirectlyviahostname')) {
|
if (System::Get('system.le_froxlor_enabled') && ($this->froxlorVhostHasLetsEncryptCert() == false || $this->froxlorVhostLetsEncryptNeedsRenew())) {
|
||||||
$mypath = makeCorrectDir(dirname(dirname(dirname(__FILE__))));
|
$this->nginx_data[$vhost_filename] .= '# temp. disabled ssl-redirect due to Let\'s Encrypt certificate generation.' . PHP_EOL;
|
||||||
|
$is_redirect = false;
|
||||||
} else {
|
} else {
|
||||||
$mypath = makeCorrectDir(dirname(dirname(dirname(dirname(__FILE__)))));
|
$_sslport = $this->checkAlternativeSslPort();
|
||||||
|
$mypath = 'https://' . Settings::Get('system.hostname') . $_sslport . '/';
|
||||||
|
$this->nginx_data[$vhost_filename] .= "\t".'return 301 '.$mypath.'$request_uri;'."\n";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// user-defined docroot, #417
|
|
||||||
$mypath = makeCorrectDir($row_ipsandports['docroot']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$is_redirect) {
|
||||||
$this->nginx_data[$vhost_filename] .= "\t".'root '.$mypath.';'."\n";
|
$this->nginx_data[$vhost_filename] .= "\t".'root '.$mypath.';'."\n";
|
||||||
$this->nginx_data[$vhost_filename] .= "\t".'index index.php index.html index.htm;'."\n\n";
|
$this->nginx_data[$vhost_filename] .= "\t".'index index.php index.html index.htm;'."\n\n";
|
||||||
$this->nginx_data[$vhost_filename] .= "\t".'location / {'."\n";
|
$this->nginx_data[$vhost_filename] .= "\t".'location / {'."\n";
|
||||||
$this->nginx_data[$vhost_filename] .= "\t".'}'."\n";
|
$this->nginx_data[$vhost_filename] .= "\t".'}'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
if ($row_ipsandports['specialsettings'] != '') {
|
if ($row_ipsandports['specialsettings'] != '') {
|
||||||
$this->nginx_data[$vhost_filename].= $this->processSpecialConfigTemplate(
|
$this->nginx_data[$vhost_filename].= $this->processSpecialConfigTemplate(
|
||||||
@@ -231,6 +235,7 @@ class nginx extends HttpConfigBase {
|
|||||||
$this->nginx_data[$vhost_filename].=$this->composeSslSettings($row_ipsandports);
|
$this->nginx_data[$vhost_filename].=$this->composeSslSettings($row_ipsandports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$is_redirect) {
|
||||||
$this->nginx_data[$vhost_filename] .= "\tlocation ~ \.php {\n";
|
$this->nginx_data[$vhost_filename] .= "\tlocation ~ \.php {\n";
|
||||||
$this->nginx_data[$vhost_filename] .= "\t\tfastcgi_split_path_info ^(.+\.php)(/.+)\$;\n";
|
$this->nginx_data[$vhost_filename] .= "\t\tfastcgi_split_path_info ^(.+\.php)(/.+)\$;\n";
|
||||||
$this->nginx_data[$vhost_filename] .= "\t\tinclude ".Settings::Get('nginx.fastcgiparams').";\n";
|
$this->nginx_data[$vhost_filename] .= "\t\tinclude ".Settings::Get('nginx.fastcgiparams').";\n";
|
||||||
@@ -264,6 +269,7 @@ class nginx extends HttpConfigBase {
|
|||||||
|
|
||||||
$this->nginx_data[$vhost_filename] .= "\t\tfastcgi_index index.php;\n";
|
$this->nginx_data[$vhost_filename] .= "\t\tfastcgi_index index.php;\n";
|
||||||
$this->nginx_data[$vhost_filename] .= "\t}\n";
|
$this->nginx_data[$vhost_filename] .= "\t}\n";
|
||||||
|
}
|
||||||
|
|
||||||
$this->nginx_data[$vhost_filename] .= "}\n\n";
|
$this->nginx_data[$vhost_filename] .= "}\n\n";
|
||||||
// End of Froxlor server{}-part
|
// End of Froxlor server{}-part
|
||||||
|
|||||||
Reference in New Issue
Block a user