Skip to content

Commit

Permalink
Added: Apache2 wildcard alias feature
Browse files Browse the repository at this point in the history
CS fixes
  • Loading branch information
nuxwin committed Jun 9, 2019
1 parent 1a00267 commit 20033f1
Show file tree
Hide file tree
Showing 30 changed files with 2,153 additions and 1,269 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Expand Up @@ -5,6 +5,7 @@ Git 1.5.x
------------------------------------------------------------------------------------------------------------------------

BACKEND
Added: Apache2 wildcard alias feature
Added: Array::Utils library (PerlVendor)
Added: iMSCP::Database::mariadb adapter (for use with new DBD::MariaDB driver for DBI, in place of DBD::mysql when available)
Added: Support for per-Milter and per-policy server timeout (Servers::mta::postfix::postconf() - Postfix >= 3.0.0)
Expand Down Expand Up @@ -43,6 +44,7 @@ DISTRIBUTIONS

FRONTEND
Added: ACL assertions for the navigation
Added: Apache2 wildcard alias feature
Added: Patches for zendframework/zendframework1 dependency (PHP deprecations, Zend_Navigation component enhancement, small fixes)
Added: Route injector service for i-MSCP plugins
Added: Service provider injector for i-MSCP plugins
Expand Down
6 changes: 5 additions & 1 deletion configs/debian/database/database.sql
Expand Up @@ -82,7 +82,7 @@ INSERT IGNORE INTO `config` (`name`, `value`) VALUES
('PREVENT_EXTERNAL_LOGIN_ADMIN', '1'),
('PREVENT_EXTERNAL_LOGIN_RESELLER', '1'),
('PREVENT_EXTERNAL_LOGIN_CLIENT', '1'),
('DATABASE_REVISION', '273');
('DATABASE_REVISION', '274');

-- --------------------------------------------------------

Expand Down Expand Up @@ -145,6 +145,7 @@ CREATE TABLE IF NOT EXISTS `domain` (
`url_forward` varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT 'no',
`type_forward` varchar(5) collate utf8_unicode_ci DEFAULT NULL,
`host_forward` varchar(3) collate utf8_unicode_ci NOT NULL DEFAULT 'Off',
`wildcard_alias` enum('yes', 'no') NOT NULL DEFAULT 'no',
PRIMARY KEY (`domain_id`),
UNIQUE KEY `domain_name` (`domain_name`),
INDEX `i_domain_admin_id` (`domain_admin_id`)
Expand All @@ -167,6 +168,7 @@ CREATE TABLE IF NOT EXISTS `domain_aliasses` (
`url_forward` varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT 'no',
`type_forward` varchar(5) collate utf8_unicode_ci DEFAULT NULL,
`host_forward` varchar(3) collate utf8_unicode_ci NOT NULL DEFAULT 'Off',
`wildcard_alias` enum('yes', 'no') NOT NULL DEFAULT 'no',
`external_mail` varchar(15) collate utf8_unicode_ci NOT NULL DEFAULT 'off',
PRIMARY KEY (`alias_id`),
INDEX `domain_id` (`domain_id`)
Expand Down Expand Up @@ -627,6 +629,7 @@ CREATE TABLE IF NOT EXISTS `subdomain` (
`subdomain_url_forward` varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT 'no',
`subdomain_type_forward` varchar(5) collate utf8_unicode_ci DEFAULT NULL,
`subdomain_host_forward` varchar(3) collate utf8_unicode_ci NOT NULL DEFAULT 'Off',
`subdomain_wildcard_alias` enum('yes', 'no') NOT NULL DEFAULT 'no',
`subdomain_status` varchar(255) collate utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`subdomain_id`),
INDEX `domain_id` (`domain_id`)
Expand All @@ -647,6 +650,7 @@ CREATE TABLE IF NOT EXISTS `subdomain_alias` (
`subdomain_alias_url_forward` varchar(255) collate utf8_unicode_ci NOT NULL DEFAULT 'no',
`subdomain_alias_type_forward` varchar(5) collate utf8_unicode_ci DEFAULT NULL,
`subdomain_alias_host_forward` varchar(3) collate utf8_unicode_ci NOT NULL DEFAULT 'Off',
`subdomain_alias_wildcard_alias` enum('yes', 'no') NOT NULL DEFAULT 'no',
`subdomain_alias_status` varchar(255) collate utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`subdomain_alias_id`),
INDEX `alias_id` (`alias_id`)
Expand Down
3 changes: 2 additions & 1 deletion engine/PerlLib/Modules/Alias.pm
Expand Up @@ -331,7 +331,8 @@ sub _getData
ALLOW_URL_FOPEN => $phpini->{'allow_url_fopen'} || 'off',
PHP_FPM_LISTEN_PORT => ( $phpini->{'id'} // 1 )-1,
EXTERNAL_MAIL => $self->{'external_mail'},
MAIL_ENABLED => ( $self->{'external_mail'} eq 'off' && ( $self->{'mail_on_domain'} || $self->{'domain_mailacc_limit'} >= 0 ) )
MAIL_ENABLED => ( $self->{'external_mail'} eq 'off' && ( $self->{'mail_on_domain'} || $self->{'domain_mailacc_limit'} >= 0 ) ),
WILDCARD_ALIAS => $self->{'wildcard_alias'} // 'no'
}
} unless %{ $self->{'_data'} };

Expand Down
5 changes: 3 additions & 2 deletions engine/PerlLib/Modules/Domain.pm
Expand Up @@ -337,7 +337,7 @@ sub _loadData
"
SELECT t1.domain_id, t1.domain_admin_id, t1.domain_mailacc_limit, t1.domain_name, t1.domain_status,
t1.domain_php, t1.domain_cgi, t1.external_mail, t1.web_folder_protection, t1.document_root,
t1.url_forward, t1.type_forward, t1.host_forward,
t1.url_forward, t1.type_forward, t1.host_forward, t1.wildcard_alias,
IFNULL(t2.ip_number, '0.0.0.0') AS ip_number,
t3.private_key, t3.certificate, t3.ca_bundle, t3.allow_hsts, t3.hsts_max_age,
t3.hsts_include_subdomains,
Expand Down Expand Up @@ -442,7 +442,8 @@ sub _getData
ALLOW_URL_FOPEN => $phpini->{'allow_url_fopen'} || 'off',
PHP_FPM_LISTEN_PORT => ( $phpini->{'id'} // 1 )-1,
EXTERNAL_MAIL => $self->{'external_mail'},
MAIL_ENABLED => ( $self->{'external_mail'} eq 'off' && ( $self->{'mail_on_domain'} || $self->{'domain_mailacc_limit'} >= 0 ) )
MAIL_ENABLED => ( $self->{'external_mail'} eq 'off' && ( $self->{'mail_on_domain'} || $self->{'domain_mailacc_limit'} >= 0 ) ),
WILDCARD_ALIAS => $self->{'wildcard_alias'} // 'no'
}
} unless %{ $self->{'_data'} };

Expand Down
3 changes: 2 additions & 1 deletion engine/PerlLib/Modules/SubAlias.pm
Expand Up @@ -255,7 +255,8 @@ sub _getData
ALLOW_URL_FOPEN => $phpini->{'allow_url_fopen'} || 'off',
PHP_FPM_LISTEN_PORT => ( $phpini->{'id'} // 1 )-1,
EXTERNAL_MAIL => $self->{'external_mail'},
MAIL_ENABLED => ( $self->{'external_mail'} eq 'off' && ( $self->{'mail_on_domain'} || $self->{'domain_mailacc_limit'} >= 0 ) )
MAIL_ENABLED => ( $self->{'external_mail'} eq 'off' && ( $self->{'mail_on_domain'} || $self->{'domain_mailacc_limit'} >= 0 ) ),
WILDCARD_ALIAS => $self->{'subdomain_alias_wildcard_alias'} // 'no'
}
} unless %{ $self->{'_data'} };

Expand Down
3 changes: 2 additions & 1 deletion engine/PerlLib/Modules/Subdomain.pm
Expand Up @@ -241,7 +241,8 @@ sub _getData
ALLOW_URL_FOPEN => $phpini->{'allow_url_fopen'} || 'off',
PHP_FPM_LISTEN_PORT => ( $phpini->{'id'} // 1 )-1,
EXTERNAL_MAIL => $self->{'external_mail'},
MAIL_ENABLED => ( $self->{'external_mail'} eq 'off' && ( $self->{'mail_on_domain'} || $self->{'domain_mailacc_limit'} >= 0 ) )
MAIL_ENABLED => ( $self->{'external_mail'} eq 'off' && ( $self->{'mail_on_domain'} || $self->{'domain_mailacc_limit'} >= 0 ) ),
WILDCARD_ALIAS => $self->{'subdomain_wildcard_alias'} // 'no'
}
} unless %{ $self->{'_data'} };

Expand Down
6 changes: 4 additions & 2 deletions engine/PerlLib/Servers/httpd/apache_fcgid.pm
Expand Up @@ -386,7 +386,8 @@ sub disableDmn
HTTP_URI_SCHEME => 'http://',
HTTPD_LOG_DIR => $self->{'config'}->{'HTTPD_LOG_DIR'},
USER_WEB_DIR => $::imscpConfig{'USER_WEB_DIR'},
SERVER_ALIASES => "www.$data->{'DOMAIN_NAME'}"
SERVER_ALIASES => ( $data->{'WILDCARD_ALIAS'} eq 'yes' ? '*.' : 'www.' )
. $data->{'DOMAIN_NAME'}
} );

# Create http vhost
Expand Down Expand Up @@ -1741,7 +1742,8 @@ sub _addCfg
HTTPD_CUSTOM_SITES_DIR => $self->{'config'}->{'HTTPD_CUSTOM_SITES_DIR'},
HTTPD_LOG_DIR => $self->{'config'}->{'HTTPD_LOG_DIR'},
PHP_FCGI_STARTER_DIR => $self->{'phpConfig'}->{'PHP_FCGI_STARTER_DIR'},
SERVER_ALIASES => "www.$data->{'DOMAIN_NAME'}"
SERVER_ALIASES => ( $data->{'WILDCARD_ALIAS'} eq 'yes' ? '*.' : 'www.' )
. $data->{'DOMAIN_NAME'}
} );

# Create http vhost
Expand Down
6 changes: 4 additions & 2 deletions engine/PerlLib/Servers/httpd/apache_itk.pm
Expand Up @@ -379,7 +379,8 @@ sub disableDmn
HTTP_URI_SCHEME => 'http://',
HTTPD_LOG_DIR => $self->{'config'}->{'HTTPD_LOG_DIR'},
USER_WEB_DIR => $::imscpConfig{'USER_WEB_DIR'},
SERVER_ALIASES => "www.$data->{'DOMAIN_NAME'}"
SERVER_ALIASES => ( $data->{'WILDCARD_ALIAS'} eq 'yes' ? '*.' : 'www.' )
. $data->{'DOMAIN_NAME'}
} );

# Create http vhost
Expand Down Expand Up @@ -1719,7 +1720,8 @@ sub _addCfg
} @domainIPs ),
HTTPD_CUSTOM_SITES_DIR => $self->{'config'}->{'HTTPD_CUSTOM_SITES_DIR'},
HTTPD_LOG_DIR => $self->{'config'}->{'HTTPD_LOG_DIR'},
SERVER_ALIASES => "www.$data->{'DOMAIN_NAME'}"
SERVER_ALIASES => ( $data->{'WILDCARD_ALIAS'} eq 'yes' ? '*.' : 'www.' )
. $data->{'DOMAIN_NAME'}
} );

# Create http vhost
Expand Down
6 changes: 4 additions & 2 deletions engine/PerlLib/Servers/httpd/apache_php_fpm.pm
Expand Up @@ -380,7 +380,8 @@ sub disableDmn
HTTP_URI_SCHEME => 'http://',
HTTPD_LOG_DIR => $self->{'config'}->{'HTTPD_LOG_DIR'},
USER_WEB_DIR => $::imscpConfig{'USER_WEB_DIR'},
SERVER_ALIASES => "www.$data->{'DOMAIN_NAME'}"
SERVER_ALIASES => ( $data->{'WILDCARD_ALIAS'} eq 'yes' ? '*.' : 'www.' )
. $data->{'DOMAIN_NAME'}
} );

# Create http vhost
Expand Down Expand Up @@ -1755,7 +1756,8 @@ sub _addCfg
? $confLevel
: '127.0.0.1:' . ( $self->{'phpConfig'}->{'PHP_FPM_LISTEN_PORT_START'}+$data->{'PHP_FPM_LISTEN_PORT'} )
),
SERVER_ALIASES => "www.$data->{'DOMAIN_NAME'}"
SERVER_ALIASES => ( $data->{'WILDCARD_ALIAS'} eq 'yes' ? '*.' : 'www.' )
. $data->{'DOMAIN_NAME'}
} );

# Create http vhost
Expand Down
27 changes: 19 additions & 8 deletions gui/library/iMSCP/Events.php
Expand Up @@ -876,7 +876,8 @@ class iMSCP_Events
* - documentRoot : Domain document root
* - forwardUrl : Domain forward URL, 'no' if no forward URL has been set
* - forwardType : Domain forward URL type
* - forwardHost : Domain forward URL preserve host option
* - forwardHost : Domain forward URL preserve host option,
* - wildcardAlias : Wildcard alias option (yes|no)
*
* @const string
*/
Expand All @@ -895,7 +896,8 @@ class iMSCP_Events
* - documentRoot : Domain document root
* - forwardUrl : Domain forward URL, 'no' if no forward URL has been set
* - forwardType : Domain forward URL type
* - forwardHost : Domain forward URL preserve host option
* - forwardHost : Domain forward URL preserve host option,
* - wildcardAlias : Wildcard alias option (yes|no)
*
* @const string
*/
Expand All @@ -911,7 +913,8 @@ class iMSCP_Events
* - documentRoot : Domain document root
* - forwardUrl : Domain forward URL, 'no' if no forward URL has been set
* - forwardType : Domain forward URL type
* - forwardHost : Domain forward URL preserve host option
* - forwardHost : Domain forward URL preserve host option,
* - wildcardAlias : Wildcard alias option (yes|no)
*
* @const string
*/
Expand Down Expand Up @@ -947,6 +950,7 @@ class iMSCP_Events
* - forwardUrl : Subdomain forward URL, 'no' if no forward URL has been set
* - forwardType : Subdomain forward URL type
* - forwardHost : Subdomain forward URL preserve host option
* - wildcardAlias : Wildcard alias option (yes|no)
* - customerId : Subdomain owner unique identifier
*
* @const string
Expand All @@ -968,6 +972,7 @@ class iMSCP_Events
* been set
* - forwardType : Subdomain forward URL type
* - forwardHost : Subdomain forward URL preserve host option
* - wildcardAlias : Wildcard alias option (yes|no)
* - customerId : Subdomain owner unique identifier
*
* @const string
Expand All @@ -987,7 +992,8 @@ class iMSCP_Events
* - forwardUrl : Subdomain forward URL, 'no' if no forward URL has
* been set
* - forwardType : Subdomain forward URL type
* - forwardHost : Subdomain forward URL preserve host option
* - forwardHost : Subdomain forward URL preserve host option,
* - wildcardAlias : Wildcard alias option (yes|no)
*
* @const string
*/
Expand All @@ -1006,7 +1012,8 @@ class iMSCP_Events
* - forwardUrl : Subdomain forward URL, 'no' if no forward URL has
* been set
* - forwardType : Subdomain forward URL type
* - forwardHost : Subdomain forward URL preserve host option
* - forwardHost : Subdomain forward URL preserve host option,
* - wildcardAlias : Wildcard alias option (yes|no)
*
* @const string
*/
Expand Down Expand Up @@ -1054,6 +1061,7 @@ class iMSCP_Events
* set
* - forwardType: Domain alias forward URL type
* - forwardHost: Domain alias forward URL preserve host option
* - wildcardAlias : Wildcard alias option (yes|no)
*
* @const string
*/
Expand All @@ -1071,7 +1079,8 @@ class iMSCP_Events
* - forwardUrl: Domain alias forward URL, 'no' if no forward URL has been
* set
* - forwardType: Domain alias forward URL type
* - forwardHost: Domain alias forward URL preserve host optio
* - forwardHost: Domain alias forward URL preserve host option
* - wildcardAlias : Wildcard alias option (yes|no)
*
* @const string
*/
Expand All @@ -1089,6 +1098,7 @@ class iMSCP_Events
* has been set
* - forwardType : Domain alias forward URL type
* - forwardHost : Domain alias forward URL preserve host option
* - wildcardAlias : Wildcard alias option (yes|no)
*
* @const string
*/
Expand All @@ -1097,15 +1107,16 @@ class iMSCP_Events
/**
* Event triggered after domain alias edition
*
* iMSCP_Events_Event objectparameters:
* iMSCP_Events_Event object parameters:
* - domainAliasId : Domain alias unique identifier
* - domainAliasName : Domain alias name
* - mountPoint : Domain alias mount point
* - documentRoot : Domain alias document root
* - forwardUrl : Domain alias forward URL, 'no' if no forward URL
* has been set
* - forwardType : Domain alias forward URL type
* - forwardHost : Domain alias forward URL preserve host option
* - forwardHost : Domain alias forward URL preserve host option,
* - wildcardAlias : Wildcard alias option (yes|no)
*
* @const string
*/
Expand Down
33 changes: 32 additions & 1 deletion gui/library/iMSCP/Update/Database.php
Expand Up @@ -64,7 +64,7 @@ class iMSCP_Update_Database extends iMSCP_Update
/**
* @var int Last database update revision
*/
protected $lastUpdate = 273;
protected $lastUpdate = 274;

/**
* Singleton - Make new unavailable
Expand Down Expand Up @@ -1977,4 +1977,35 @@ protected function r273()
throw new RuntimeException($e->getMessage());
}
}

/**
* Add columns for the Apache2 wildcard alias feature
*
* @return array SQL statements to be executed
*/
protected function r274()
{
return [
$this->addColumn(
'domain',
'wildcard_alias',
"enum('yes', 'no') NOT NULL DEFAULT 'no' AFTER `host_forward`"
),
$this->addColumn(
'subdomain',
'subdomain_wildcard_alias',
"enum('yes', 'no') NOT NULL DEFAULT 'no' AFTER `subdomain_host_forward`"
),
$this->addColumn(
'domain_aliasses',
'wildcard_alias',
"enum('yes', 'no') NOT NULL DEFAULT 'no' AFTER `host_forward`"
),
$this->addColumn(
'subdomain_alias',
'subdomain_alias_wildcard_alias',
"enum('yes', 'no') NOT NULL DEFAULT 'no' AFTER `subdomain_alias_host_forward`"
)
];
}
}

0 comments on commit 20033f1

Please sign in to comment.