tbrehm
2011-09-22 a7bdf8d0bfd77eb99f1972dd41f04a068212361a
Implemented: FS#334 - IPv6 support
Implemented: FS#1113 - Force client to use only allowed IPs
5 files deleted
8 files modified
1 files added
574 ■■■■ changed files
install/sql/incremental/upd_0022.sql 1 ●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql 1 ●●●● patch | view | raw | blame | history
interface/web/sites/ajax_get_ip.php 4 ●●● patch | view | raw | blame | history
interface/web/sites/form/web_domain.tform.php 17 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_web_domain.lng 3 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/web_domain_edit.htm 17 ●●●● patch | view | raw | blame | history
interface/web/sites/web_domain_edit.php 58 ●●●● patch | view | raw | blame | history
server/conf/nginx_reverseproxy_rewrites.conf.master 9 ●●●●● patch | view | raw | blame | history
server/conf/nginx_reverseproxy_vhost.conf.master 69 ●●●●● patch | view | raw | blame | history
server/conf/ufw.before.rules.master 78 ●●●●● patch | view | raw | blame | history
server/conf/ufw.conf.master 8 ●●●●● patch | view | raw | blame | history
server/conf/ufw.default.master 39 ●●●●● patch | view | raw | blame | history
server/conf/vhost.conf.master 241 ●●●●● patch | view | raw | blame | history
server/plugins-available/apache2_plugin.inc.php 29 ●●●●● patch | view | raw | blame | history
install/sql/incremental/upd_0022.sql
New file
@@ -0,0 +1 @@
ALTER TABLE  `web_domain` ADD  `ipv6_address` VARCHAR( 255 ) default NULL AFTER  `ip_address`;
install/sql/ispconfig3.sql
@@ -1474,6 +1474,7 @@
  `sys_perm_other` varchar(5) default NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `ip_address` varchar(39) default NULL,
  `ipv6_address` VARCHAR( 255 ) default NULL
  `domain` varchar(255) default NULL,
  `type` varchar(32) default NULL,
  `parent_domain_id` int(11) unsigned NOT NULL default '0',
interface/web/sites/ajax_get_ip.php
@@ -35,10 +35,12 @@
$app->auth->check_module_permissions('sites');
$server_id = intval($_GET["server_id"]);
$client_group_id = intval($_GET["client_group_id"]);
$ip_type = $app->db->quote($_GET['ip_type']);
if($_SESSION["s"]["user"]["typ"] == 'admin') {
    $sql = "SELECT ip_address FROM server_ip WHERE server_id = $server_id";
    $sql = "SELECT ip_address FROM server_ip WHERE ip_type = '$ip_type' AND server_id = $server_id";
    $ips = $app->db->queryAllRecords($sql);
    // $ip_select = "<option value=''></option>";
    $ip_select = "*";
interface/web/sites/form/web_domain.tform.php
@@ -82,11 +82,22 @@
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT ip_address,ip_address FROM server_ip WHERE {AUTHSQL} ORDER BY ip_address',
            /*'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => "SELECT ip_address,ip_address FROM server_ip WHERE ip_type = 'IPv4' AND {AUTHSQL} ORDER BY ip_address",
                                        'keyfield'=> 'ip_address',
                                        'valuefield'=> 'ip_address'
                                     ),
                                     ),*/
            'value'        => ''
        ),
        'ipv6_address' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => '',
            /*'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => "SELECT ip_address,ip_address FROM server_ip WHERE ip_type = 'IPv6' AND {AUTHSQL} ORDER BY ip_address",
                                        'keyfield'=> 'ip_address',
                                        'valuefield'=> 'ip_address'
                                     ),*/
            'value'        => ''
        ),
        'domain' => array (
interface/web/sites/lib/lang/en_web_domain.lng
@@ -21,7 +21,8 @@
$wb["document_root_txt"] = 'Documentroot';
$wb["system_user_txt"] = 'Linux User';
$wb["system_group_txt"] = 'Linux Group';
$wb["ip_address_txt"] = 'IP-Address';
$wb["ip_address_txt"] = 'IPv4-Address';
$wb["ipv6_address_txt"] = 'IPv6-Address';
$wb["vhost_type_txt"] = 'VHost Type';
$wb["hd_quota_txt"] = 'Harddisk Quota';
$wb["traffic_quota_txt"] = 'Traffic Quota';
interface/web/sites/templates/web_domain_edit.htm
@@ -15,14 +15,14 @@
        <input type="hidden" name="server_id" value="{tmpl_var name='server_id_value'}" />
        <tmpl_else>
        <label for="server_id">{tmpl_var name='server_id_txt'}</label>
        <select name="server_id" id="server_id" class="selectInput" onChange="loadOptionInto('ip_address','sites/ajax_get_ip.php?server_id='+document.getElementById('server_id').value)">
        <select name="server_id" id="server_id" class="selectInput" onChange="reloadWebIP()">
          {tmpl_var name='server_id'}
        </select>
        </tmpl_if>
      </div>
      <div class="ctrlHolder">
          <label for="client_group_id">{tmpl_var name='client_group_id_txt'}</label>
        <select name="client_group_id" id="client_group_id" class="selectInput">
        <select name="client_group_id" id="client_group_id" class="selectInput" onChange="reloadWebIP()">
                    {tmpl_var name='client_group_id'}
                </select>
      </div>
@@ -30,7 +30,7 @@
      <tmpl_if name="is_reseller">
      <div class="ctrlHolder">
          <label for="client_group_id">{tmpl_var name='client_group_id_txt'}</label>
        <select name="client_group_id" id="client_group_id" class="selectInput">
        <select name="client_group_id" id="client_group_id" class="selectInput" onChange="reloadWebIP()">
                    {tmpl_var name='client_group_id'}
                </select>
      </div>
@@ -39,6 +39,12 @@
          <label for="ip_address">{tmpl_var name='ip_address_txt'}</label>
        <select name="ip_address" id="ip_address" class="selectInput formLengthIPv4">
                    {tmpl_var name='ip_address'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="ipv6_address">{tmpl_var name='ipv6_address_txt'}</label>
        <select name="ipv6_address" id="ipv6_address" class="selectInput formLengthIPv4">
                    {tmpl_var name='ipv6_address'}
                </select>
      </div>
      <div class="ctrlHolder">
@@ -158,5 +164,10 @@
                }
            });
        }
        function reloadWebIP() {
            loadOptionInto('ip_address','sites/ajax_get_ip.php?ip_type=IPv4&server_id='+document.getElementById('server_id').value)&client_group_id='+document.getElementById('client_group_id').value);
            loadOptionInto('ipv6_address','sites/ajax_get_ip.php?ip_type=IPv6&server_id='+document.getElementById('server_id').value)&client_group_id='+document.getElementById('client_group_id').value);
        }
            
</script>
interface/web/sites/web_domain_edit.php
@@ -94,8 +94,8 @@
            $app->tpl->setVar("server_id","<option value='$client[default_webserver]'>$tmp[server_name]</option>");
            unset($tmp);
            // Fill the IP select field with the IP addresses that are allowed for this client
            $sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND client_id=0 OR client_id=".$_SESSION['s']['user']['client_id'];
            //* Fill the IPv4 select field with the IP addresses that are allowed for this client
            $sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
            $ips = $app->db->queryAllRecords($sql);
            $ip_select = "<option value='*'>*</option>";
            //$ip_select = "";
@@ -106,6 +106,21 @@
                }
            }
            $app->tpl->setVar("ip_address",$ip_select);
            unset($tmp);
            unset($ips);
            //* Fill the IPv6 select field with the IP addresses that are allowed for this client
            $sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
            $ips = $app->db->queryAllRecords($sql);
            $ip_select = "<option value=''></option>";
            //$ip_select = "";
            if(is_array($ips)) {
                foreach( $ips as $ip) {
                    $selected = ($ip["ip_address"] == $this->dataRecord["ipv6_address"])?'SELECTED':'';
                    $ip_select .= "<option value='$ip[ip_address]' $selected>$ip[ip_address]</option>\r\n";
                }
            }
            $app->tpl->setVar("ipv6_address",$ip_select);
            unset($tmp);
            unset($ips);
@@ -135,8 +150,8 @@
            }
            $app->tpl->setVar("client_group_id",$client_select);
            // Fill the IP select field with the IP addresses that are allowed for this client
            $sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND client_id=0 OR client_id=".$_SESSION['s']['user']['client_id'];
            //* Fill the IPv4 select field with the IP addresses that are allowed for this client
            $sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
            $ips = $app->db->queryAllRecords($sql);
            $ip_select = "<option value='*'>*</option>";
            //$ip_select = "";
@@ -147,6 +162,21 @@
                }
            }
            $app->tpl->setVar("ip_address",$ip_select);
            unset($tmp);
            unset($ips);
            //* Fill the IPv6 select field with the IP addresses that are allowed for this client
            $sql = "SELECT ip_address FROM server_ip WHERE server_id = ".$client['default_webserver']." AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".$_SESSION['s']['user']['client_id'].")";
            $ips = $app->db->queryAllRecords($sql);
            $ip_select = "<option value=''></option>";
            //$ip_select = "";
            if(is_array($ips)) {
                foreach( $ips as $ip) {
                    $selected = ($ip["ip_address"] == $this->dataRecord["ipv6_address"])?'SELECTED':'';
                    $ip_select .= "<option value='$ip[ip_address]' $selected>$ip[ip_address]</option>\r\n";
                }
            }
            $app->tpl->setVar("ipv6_address",$ip_select);
            unset($tmp);
            unset($ips);
@@ -161,8 +191,9 @@
                $tmp = $app->db->queryOneRecord("SELECT server_id FROM server WHERE web_server = 1 ORDER BY server_name LIMIT 0,1");
                $server_id = $tmp['server_id'];
            }
            $sql = "SELECT ip_address FROM server_ip WHERE server_id = $server_id";
            //* Fill the IPv4 select field
            $sql = "SELECT ip_address FROM server_ip WHERE ip_type = 'IPv4' AND server_id = $server_id";
            $ips = $app->db->queryAllRecords($sql);
            $ip_select = "<option value='*'>*</option>";
            //$ip_select = "";
@@ -175,6 +206,21 @@
            $app->tpl->setVar("ip_address",$ip_select);
            unset($tmp);
            unset($ips);
            //* Fill the IPv6 select field
            $sql = "SELECT ip_address FROM server_ip WHERE ip_type = 'IPv6' AND server_id = $server_id";
            $ips = $app->db->queryAllRecords($sql);
            $ip_select = "<option value=''></option>";
            //$ip_select = "";
            if(is_array($ips)) {
                foreach( $ips as $ip) {
                    $selected = ($ip["ip_address"] == $this->dataRecord["ipv6_address"])?'SELECTED':'';
                    $ip_select .= "<option value='$ip[ip_address]' $selected>$ip[ip_address]</option>\r\n";
                }
            }
            $app->tpl->setVar("ipv6_address",$ip_select);
            unset($tmp);
            unset($ips);
            // Fill the client select field
            $sql = "SELECT groupid, name FROM sys_group WHERE client_id > 0 ORDER BY name";
server/conf/nginx_reverseproxy_rewrites.conf.master
File was deleted
server/conf/nginx_reverseproxy_vhost.conf.master
File was deleted
server/conf/ufw.before.rules.master
File was deleted
server/conf/ufw.conf.master
File was deleted
server/conf/ufw.default.master
File was deleted
server/conf/vhost.conf.master
@@ -5,7 +5,8 @@
    Deny from all
</Directory>
<VirtualHost <tmpl_var name='ip_address'>:80>
<tmpl_loop name="vhosts">
<VirtualHost {tmpl_var name='ip_address'}:{tmpl_var name='port'}>
<tmpl_if name='php' op='==' value='suphp'>
    DocumentRoot <tmpl_var name='web_document_root'>
</tmpl_else>
@@ -34,7 +35,17 @@
    ErrorDocument 500 /error/500.html
    ErrorDocument 503 /error/503.html
</tmpl_if>
    <IfModule mod_ssl.c>
<tmpl_if name='ssl_enabled'>
    SSLEngine on
    SSLCertificateFile <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.crt
    SSLCertificateKeyFile <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.key
</tmpl_if>
<tmpl_if name='has_bundle_cert'>
    SSLCACertificateFile <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.bundle
</tmpl_if>
    </IfModule>
    <Directory {tmpl_var name='web_document_root_www'}>
        Options FollowSymLinks
        AllowOverride <tmpl_var name='allow_override'>
@@ -225,228 +236,4 @@
<tmpl_var name='apache_directives'>
</VirtualHost>
<tmpl_if name='ssl_enabled'>
<IfModule mod_ssl.c>
###########################################################
# SSL Vhost
###########################################################
<VirtualHost <tmpl_var name='ip_address'>:443>
<tmpl_if name='php' op='==' value='suphp'>
    DocumentRoot <tmpl_var name='web_document_root'>
</tmpl_else>
  <tmpl_if name='php' op='==' value='cgi'>
    DocumentRoot <tmpl_var name='web_document_root'>
  </tmpl_else>
    DocumentRoot <tmpl_var name='web_document_root_www'>
  </tmpl_if>
</tmpl_if>
    ServerName <tmpl_var name='ssl_domain'>
<tmpl_if name='alias'>
    <tmpl_var name='alias'>
</tmpl_if>
    ServerAdmin webmaster@<tmpl_var name='domain'>
    ErrorLog /var/log/ispconfig/httpd/<tmpl_var name='domain'>/error.log
<tmpl_if name='errordocs'>
    ErrorDocument 400 /error/400.html
    ErrorDocument 401 /error/401.html
    ErrorDocument 403 /error/403.html
    ErrorDocument 404 /error/404.html
    ErrorDocument 405 /error/405.html
    ErrorDocument 500 /error/500.html
    ErrorDocument 503 /error/503.html
</tmpl_if>
    SSLEngine on
    SSLCertificateFile <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.crt
    SSLCertificateKeyFile <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.key
<tmpl_if name='has_bundle_cert'>
    SSLCACertificateFile <tmpl_var name='document_root'>/ssl/<tmpl_var name='ssl_domain'>.bundle
</tmpl_if>
    <Directory {tmpl_var name='web_document_root_www'}>
        Options FollowSymLinks
        AllowOverride <tmpl_var name='allow_override'>
        Order allow,deny
        Allow from all
<tmpl_if name='ssi' op='==' value='y'>
        # ssi enabled
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
        Options +Includes
</tmpl_if>
<tmpl_if name='php' op='==' value='no'>
        <Files ~ '.php[s3-6]{0,1}$'>
            Order allow,deny
            Deny from all
            Allow from none
        </Files>
</tmpl_if>
    </Directory>
    <Directory {tmpl_var name='web_document_root'}>
        Options FollowSymLinks
        AllowOverride <tmpl_var name='allow_override'>
        Order allow,deny
        Allow from all
<tmpl_if name='ssi' op='==' value='y'>
        # ssi enabled
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
        Options +Includes
</tmpl_if>
<tmpl_if name='php' op='==' value='no'>
        <Files ~ '.php[s3-6]{0,1}$'>
            Order allow,deny
            Deny from all
            Allow from none
        </Files>
</tmpl_if>
    </Directory>
<tmpl_if name='cgi' op='==' value='y'>
    # cgi enabled
    <Directory {tmpl_var name='document_root'}/cgi-bin>
      Order allow,deny
      Allow from all
    </Directory>
    ScriptAlias  /cgi-bin/ <tmpl_var name='document_root'>/cgi-bin/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl
</tmpl_if>
<tmpl_if name='ssi'op='==' value='y'>
    # ssi enabled
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</tmpl_if>
<tmpl_if name='suexec'op='==' value='y'>
    # suexec enabled
    SuexecUserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'>
</tmpl_if>
# Clear PHP settings of this website
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler None
    </FilesMatch>
<tmpl_if name='php' op='==' value='mod'>
    # mod_php enabled
    AddType application/x-httpd-php .php .php3 .php4 .php5
    php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@<tmpl_var name='domain'>"
    php_admin_value upload_tmp_dir <tmpl_var name='document_root'>/tmp
    php_admin_value session.save_path <tmpl_var name='document_root'>/tmp
    # PHPIniDir <tmpl_var name='custom_php_ini_dir'>
<tmpl_if name='security_level' op='==' value='20'>
    php_admin_value open_basedir <tmpl_var name='php_open_basedir'>
</tmpl_if>
</tmpl_if>
<tmpl_if name='php' op='==' value='suphp'>
    # suphp enabled
    <Directory {tmpl_var name='web_document_root'}>
        <IfModule mod_suphp.c>
        suPHP_Engine on
        # suPHP_UserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'>
<tmpl_if name='has_custom_php_ini'>
    suPHP_ConfigPath <tmpl_var name='custom_php_ini_dir'>
</tmpl_if>
        AddHandler x-httpd-suphp .php .php3 .php4 .php5
        suPHP_AddHandler x-httpd-suphp
        </IfModule>
    </Directory>
</tmpl_if>
<tmpl_if name='php' op='==' value='cgi'>
    # php as cgi enabled
    ScriptAlias /php5-cgi <tmpl_var name='cgi_starter_path'><tmpl_var name='cgi_starter_script'>
    Action php5-cgi /php5-cgi
    AddHandler php5-cgi .php .php3 .php4 .php5
    <Directory {tmpl_var name='cgi_starter_path'}>
        Order allow,deny
        Allow from all
    </Directory>
</tmpl_if>
<tmpl_if name='php' op='==' value='fast-cgi'>
    # php as fast-cgi enabled
    # See: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
    <IfModule mod_fcgid.c>
<tmpl_if name='fastcgi_config_syntax' op='==' value='2'>
      FcgidIdleTimeout 300
      FcgidProcessLifeTime 3600
      FcgidMaxProcesses 1000
      FcgidMinProcessesPerClass 0
      FcgidMaxProcessesPerClass 100
      FcgidConnectTimeout 3
      FcgidIOTimeout 360
      FcgidBusyTimeout 300
<tmpl_else>
      IdleTimeout 300
      ProcessLifeTime 3600
      # MaxProcessCount 1000
      DefaultMinClassProcessCount 0
      DefaultMaxClassProcessCount 100
      IPCConnectTimeout 3
      IPCCommTimeout 360
      BusyTimeout 300
</tmpl_if>
    </IfModule>
    <Directory {tmpl_var name='web_document_root_www'}>
        AddHandler fcgid-script .php .php3 .php4 .php5
        FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php
        Options +ExecCGI
        AllowOverride <tmpl_var name='allow_override'>
        Order allow,deny
        Allow from all
    </Directory>
    <Directory {tmpl_var name='web_document_root'}>
        AddHandler fcgid-script .php .php3 .php4 .php5
        FCGIWrapper <tmpl_var name='fastcgi_starter_path'><tmpl_var name='fastcgi_starter_script'> .php
        Options +ExecCGI
        AllowOverride <tmpl_var name='allow_override'>
        Order allow,deny
        Allow from all
    </Directory>
</tmpl_if>
<tmpl_if name="rewrite_enabled">
    RewriteEngine on
<tmpl_if name='seo_redirect_enabled'>
    RewriteCond %{HTTP_HOST} ^<tmpl_var name='seo_redirect_origin_domain'>$ [NC]
    RewriteRule ^(.*)$ https://<tmpl_var name='seo_redirect_target_domain'>/$1 [R=301,L]
</tmpl_if>
<tmpl_loop name="redirects">
    RewriteCond %{HTTP_HOST}   ^<tmpl_var name='rewrite_domain'> [NC]
    RewriteRule   ^/(.*)$ <tmpl_var name='rewrite_target_ssl'>$1  <tmpl_var name='rewrite_type'>
</tmpl_loop>
</tmpl_if>
    # add support for apache mpm_itk
    <IfModule mpm_itk_module>
      AssignUserId <tmpl_var name='system_user'> <tmpl_var name='system_group'>
    </IfModule>
    <IfModule mod_dav_fs.c>
      # Do not execute PHP files in webdav directory
      <Directory {tmpl_var name='document_root'}/webdav>
        <FilesMatch "\.ph(p3?|tml)$">
          SetHandler None
        </FilesMatch>
      </Directory>
      # DO NOT REMOVE THE COMMENTS!
      # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
      # WEBDAV BEGIN
      # WEBDAV END
    </IfModule>
<tmpl_var name='apache_directives'>
</VirtualHost>
</IfModule>
</tmpl_if>
</tmpl_loop>
server/plugins-available/apache2_plugin.inc.php
@@ -651,6 +651,7 @@
        $tpl->newTemplate('vhost.conf.master');
        $vhost_data = $data['new'];
        //unset($vhost_data['ip_address']);
        $vhost_data['web_document_root'] = $data['new']['document_root'].'/web';
        $vhost_data['web_document_root_www'] = $web_config['website_basedir'].'/'.$data['new']['domain'].'/web';
        $vhost_data['web_basedir'] = $web_config['website_basedir'];
@@ -668,6 +669,7 @@
        $crt_file = $ssl_dir.'/'.$domain.'.crt';
        $bundle_file = $ssl_dir.'/'.$domain.'.bundle';
        /*
        if($domain!='' && $data['new']['ssl'] == 'y' && @is_file($crt_file) && @is_file($key_file) && (@filesize($crt_file)>0)  && (@filesize($key_file)>0)) {
            $vhost_data['ssl_enabled'] = 1;
            $app->log('Enable SSL for: '.$domain,LOGLEVEL_DEBUG);
@@ -675,6 +677,7 @@
            $vhost_data['ssl_enabled'] = 0;
            $app->log('SSL Disabled. '.$domain,LOGLEVEL_DEBUG);
        }
        */
        if(@is_file($bundle_file)) $vhost_data['has_bundle_cert'] = 1;
@@ -951,6 +954,32 @@
        //* Make a backup copy of vhost file
        if(file_exists($vhost_file)) copy($vhost_file,$vhost_file.'~');
        
        //* create empty vhost array
        $vhosts = array();
        //* Add vhost for ipv4 IP
        $vhosts[] = array('ip_address' => $data['new']['ip_address'], 'ssl_enabled' => 0, 'port' => 80 );
        //* Add vhost for ipv4 IP with SSL
        if($data['new']['ssl_domain'] != '' && $data['new']['ssl'] == 'y' && @is_file($crt_file) && @is_file($key_file) && (@filesize($crt_file)>0)  && (@filesize($key_file)>0)) {
            $vhosts[] = array('ip_address' => $data['new']['ip_address'], 'ssl_enabled' => 1, 'port' => '443' );
            $app->log('Enable SSL for: '.$domain,LOGLEVEL_DEBUG);
        }
        //* Add vhost for IPv6 IP
        if($data['new']['ipv6_address'] != '') {
            $vhosts[] = array('ip_address' => '['.$data['new']['ipv6_address'].']', 'ssl_enabled' => 0, 'port' => 80 );
            //* Add vhost for ipv6 IP with SSL
            if($data['new']['ssl_domain'] != '' && $data['new']['ssl'] == 'y' && @is_file($crt_file) && @is_file($key_file) && (@filesize($crt_file)>0)  && (@filesize($key_file)>0)) {
                $vhosts[] = array('ip_address' => '['.$data['new']['ipv6_address'].']', 'ssl_enabled' => 1, 'port' => '443' );
                $app->log('Enable SSL for IPv6: '.$domain,LOGLEVEL_DEBUG);
            }
        }
        //* Set the vhost loop
        $tpl->setLoop('vhosts',$vhosts);
        //* Write vhost file
        file_put_contents($vhost_file,$tpl->grab());
        $app->log('Writing the vhost file: '.$vhost_file,LOGLEVEL_DEBUG);