diff --git a/install/dist/lib/fedora.lib.php b/install/dist/lib/fedora.lib.php index b9581c2d0c6b3f8ecc0dfd8b1947c0d7a39114db..ae90f1f898f625ac7840e8ee858fde0cb577579b 100644 --- a/install/dist/lib/fedora.lib.php +++ b/install/dist/lib/fedora.lib.php @@ -521,14 +521,28 @@ class installer_dist extends installer_base { $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir']; // copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf'); - $content = rf("tpl/apache_ispconfig.conf.master"); - $records = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'"); + $content = rf('tpl/apache_ispconfig.conf.master'); + $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); + if(is_array($records) && count($records) > 0) { foreach($records as $rec) { - $content .= "NameVirtualHost ".$rec["ip_address"].":80\n"; - $content .= "NameVirtualHost ".$rec["ip_address"].":443\n"; + if($rec['ip_type'] == 'IPv6') { + $ip_address = '['.$rec['ip_address'].']'; + } else { + $ip_address = $rec['ip_address']; + } + $ports = explode(',',$rec['virtualhost_port']); + if(is_array($ports)) { + foreach($ports as $port) { + $port = intval($port); + if($port > 0 && $port < 65536 && $ip_address != '') { + $content .= 'NameVirtualHost '.$ip_address.":".$port."\n"; + } + } + } } } + $content .= "\n"; wf($vhost_conf_dir.'/ispconfig.conf',$content); diff --git a/install/dist/lib/opensuse.lib.php b/install/dist/lib/opensuse.lib.php index fb28d31ce356497acf6a2f1b8baa2bec4dd0ac44..dabddce0a4ff9c4bd133b1b0de1ce18cf98333e3 100644 --- a/install/dist/lib/opensuse.lib.php +++ b/install/dist/lib/opensuse.lib.php @@ -535,14 +535,28 @@ class installer_dist extends installer_base { $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir']; //copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf'); - $content = rf("tpl/apache_ispconfig.conf.master"); - $records = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'"); + $content = rf('tpl/apache_ispconfig.conf.master'); + $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); + if(is_array($records) && count($records) > 0) { foreach($records as $rec) { - $content .= "NameVirtualHost ".$rec["ip_address"].":80\n"; - $content .= "NameVirtualHost ".$rec["ip_address"].":443\n"; + if($rec['ip_type'] == 'IPv6') { + $ip_address = '['.$rec['ip_address'].']'; + } else { + $ip_address = $rec['ip_address']; + } + $ports = explode(',',$rec['virtualhost_port']); + if(is_array($ports)) { + foreach($ports as $port) { + $port = intval($port); + if($port > 0 && $port < 65536 && $ip_address != '') { + $content .= 'NameVirtualHost '.$ip_address.":".$port."\n"; + } + } + } } } + $content .= "\n"; wf($vhost_conf_dir.'/ispconfig.conf',$content); diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index f3e7ef4be83eb9ed49703f6114109e0976ee3a8b..d1fee8a0adfb8e9b23365a76bf7e076945d86b87 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1145,15 +1145,29 @@ class installer_base { $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir']; // copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf'); - + $content = rf('tpl/apache_ispconfig.conf.master'); $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); + if(is_array($records) && count($records) > 0) { foreach($records as $rec) { - $content .= 'NameVirtualHost '.$rec['ip_address'].":80\n"; - $content .= 'NameVirtualHost '.$rec['ip_address'].":443\n"; + if($rec['ip_type'] == 'IPv6') { + $ip_address = '['.$rec['ip_address'].']'; + } else { + $ip_address = $rec['ip_address']; + } + $ports = explode(',',$rec['virtualhost_port']); + if(is_array($ports)) { + foreach($ports as $port) { + $port = intval($port); + if($port > 0 && $port < 65536 && $ip_address != '') { + $content .= 'NameVirtualHost '.$ip_address.":".$port."\n"; + } + } + } } } + $content .= "\n"; wf($vhost_conf_dir.'/ispconfig.conf',$content); diff --git a/interface/web/admin/form/server_ip.tform.php b/interface/web/admin/form/server_ip.tform.php index 2832efbc4bbe14487bd3c5a91e28d3ea77686654..a6d9bcf57802f617ca63af25608519029eb19a51 100644 --- a/interface/web/admin/form/server_ip.tform.php +++ b/interface/web/admin/form/server_ip.tform.php @@ -137,7 +137,11 @@ $form["tabs"]['server_ip'] = array ( 'virtualhost_port' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', - 'default' => '', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^([0-9]{1,5}\,{0,1}){1,}$/i', + 'errmsg'=> 'error_port_syntax'), + ), + 'default' => '80,443', 'value' => '', 'separator' => '', 'width' => '15', diff --git a/interface/web/admin/lib/lang/en_server_ip.lng b/interface/web/admin/lib/lang/en_server_ip.lng index f67e8e82cb3270ee08bafc4ee97ff55436078426..fd91fc30d644fc9d7786a9736bf80858c3f939c1 100644 --- a/interface/web/admin/lib/lang/en_server_ip.lng +++ b/interface/web/admin/lib/lang/en_server_ip.lng @@ -7,4 +7,5 @@ $wb["virtualhost_txt"] = 'HTTP NameVirtualHost'; $wb["virtualhost_port_txt"] = 'HTTP Ports'; $wb["ip_error_wrong"] = 'The IP address is invalid'; $wb["ip_error_unique"] = 'The IP address must be unique'; +$wb["error_port_syntax"] = 'Invalid chars in port field, please enter only comma separated numbers. Example: 80,443'; ?> \ No newline at end of file diff --git a/server/conf/apache_ispconfig.conf.master b/server/conf/apache_ispconfig.conf.master index 8723d930c5eed3dfe7e7fd0f6cc9168f70b9d175..1c0d367ce43e3e6700428ec772e0a29786415137 100644 --- a/server/conf/apache_ispconfig.conf.master +++ b/server/conf/apache_ispconfig.conf.master @@ -50,7 +50,6 @@ CustomLog "| /usr/local/ispconfig/server/scripts/vlogger -s access.log -t \"%Y%m Alias /awstats-icon "/usr/share/awstats/icon" -NameVirtualHost {tmpl_var name="ip_address"}:80 -NameVirtualHost {tmpl_var name="ip_address"}:443 +NameVirtualHost {tmpl_var name="ip_address"}:{tmpl_var name="port"} diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index 092ba63d0f75c53545fe5165bb7ce6ead3e71e2a..2f641b1ae2851893658ab4dbdcb83aeb8647a309 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -1181,9 +1181,30 @@ class apache2_plugin { $tpl = new tpl(); $tpl->newTemplate('apache_ispconfig.conf.master'); $records = $app->db->queryAllRecords('SELECT * FROM server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); - - if(count($records) > 0) { - $tpl->setLoop('ip_adresses',$records); + + $records_out= array(); + if(is_array($records)) { + foreach($records as $rec) { + if($rec['ip_type'] == 'IPv6') { + $ip_address = '['.$rec['ip_address'].']'; + } else { + $ip_address = $rec['ip_address']; + } + $ports = explode(',',$rec['virtualhost_port']); + if(is_array($ports)) { + foreach($ports as $port) { + $port = intval($port); + if($port > 0 && $port < 65536 && $ip_address != '') { + $records_out[] = array('ip_address' => $ip_address, 'port' => $port); + } + } + } + } + } + + + if(count($records_out) > 0) { + $tpl->setLoop('ip_adresses',$records_out); } $vhost_file = escapeshellcmd($web_config['vhost_conf_dir'].'/ispconfig.conf');