Skip to content

Commit 0ea264c

Browse files
committed
ISPConfig writes namevirtualhost directives.
1 parent 0bd3715 commit 0ea264c

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

server/conf/apache.conf.master

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
################################################
3+
# ISPConfig Logfile configuration for vlogger
4+
################################################
5+
6+
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined_ispconfig
7+
CustomLog "| /usr/sbin/vlogger -s access.log -t \"%Y%m%d-access.log\" /var/log/ispconfig/httpd" combined_ispconfig
8+
9+
<tmpl_loop name="ip_adresses">
10+
NameVirtualHost {tmpl_var name="ip_address"}:80
11+
NameVirtualHost {tmpl_var name="ip_address"}:443
12+
</tmpl_loop>

server/plugins-available/apache2_plugin.inc.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,24 @@ function delete($event_name,$data) {
721721
function server_ip($event_name,$data) {
722722
global $app, $conf;
723723

724-
// Here we write the name virtualhost directives
725-
// NameVirtualHost IP:80
726-
// NameVirtualHost IP:443
724+
// load the server configuration options
725+
$app->uses("getconf");
726+
$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
727+
728+
$app->load('tpl');
729+
730+
$tpl = new tpl();
731+
$tpl->newTemplate("apache_ispconfig.conf.master");
732+
$records = $app->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'");
733+
734+
if(count($records) > 0) {
735+
$tpl->setLoop('ip_adresses',$records);
736+
}
737+
738+
$vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/ispconfig.conf');
739+
file_put_contents($vhost_file,$tpl->grab());
740+
$app->log("Writing the conf file: ispconfig.conf",LOGLEVEL_DEBUG);
741+
unset($tpl);
727742

728743
}
729744

0 commit comments

Comments
 (0)