Explorar el Código

Fix 1930 Add template when webmail is disabled (#1934)

* Fixed issue where ssl was not possible when webmail is disabled

Also fix the issue when importing from 1.3.5 or older / VestaCP

* Update change log
Jaap Marcus hace 4 años
padre
commit
c33c8ae2a5

+ 9 - 0
CHANGELOG.md

@@ -1,6 +1,15 @@
 # Changelog
 All notable changes to this project will be documented in this file.
 
+## [1.4.4] - Service release
+
+### Features
+
+
+### Bugfixes
+
+- Add template for when webmail is disabled allowing to generate SSL. 
+
 ## [1.4.3] - Service release
 
 ### Features

+ 7 - 2
bin/v-add-mail-domain-webmail

@@ -60,7 +60,7 @@ check_args '2' "$#" 'USER DOMAIN [WEBMAIL] [RESTART]'
 is_format_valid 'user' 'domain'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_system_enabled "$IMAP_SYSTEM" 'IMAP_SYSTEM'
-is_type_valid "$WEBMAIL_SYSTEM" "$webmail"
+is_type_valid "$WEBMAIL_SYSTEM disabled" "$webmail"
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_valid 'mail' 'DOMAIN' "$domain"
@@ -126,11 +126,16 @@ else
         if [ "$WEB_SYSTEM" = "nginx" ]; then
             WEBMAIL_TEMPLATE="web_system"
         fi
-    else
+    elif [ "$webmail" == "rainloop" ]; then
         WEBMAIL_TEMPLATE="rainloop"
         if [ ! -z "$PROXY_SYSTEM" ]; then
             PROXY_TEMPLATE="default_rainloop"
         fi
+    else
+        WEBMAIL_TEMPLATE="disabled"
+        if [ ! -z "$PROXY_SYSTEM" ]; then
+            PROXY_TEMPLATE="disabled"
+        fi
     fi
     
     add_webmail_config "$WEB_SYSTEM" "${WEBMAIL_TEMPLATE}.tpl"

+ 5 - 0
func/rebuild.sh

@@ -588,6 +588,11 @@ rebuild_mail_domain_conf() {
         if [ ! -e $HOMEDIR/$user/mail/$domain_idn ]; then
             mkdir "$HOMEDIR/$user/mail/$domain_idn"
         fi
+        
+        # Webamil client
+        if [ "$WEBAMIL" = '' ]; then
+           $HESTIA/bin/v-add-mail-domain-webmail $user $domain 'roundcube' 'no'
+        fi
 
         # Adding catchall email
         dom_aliases=$HOMEDIR/$user/conf/mail/$domain/aliases

+ 22 - 0
install/deb/templates/mail/apache2/disabled.stpl

@@ -0,0 +1,22 @@
+<VirtualHost %ip%:%web_ssl_port%>
+    ServerName %domain_idn%
+    ServerAlias %alias%
+    Alias / /var/lib/roundcube/
+    Alias /error/ %home%/%user%/web/%root_domain%/document_errors/
+    #SuexecUserGroup %user% %group%
+    
+    SSLEngine on
+    SSLVerifyClient none
+    SSLCertificateFile         %home%/%user%/conf/mail/%root_domain%/ssl/%root_domain%.crt
+    SSLCertificateKeyFile      %home%/%user%/conf/mail/%root_domain%/ssl/%root_domain%.key
+    
+    <Directory /var/www/html>
+        Options +FollowSymLinks
+        AllowOverride All
+        order allow,deny
+        allow from all
+    </Directory>
+
+    IncludeOptional %home%/%user%/conf/mail/%root_domain%/%web_system%.ssl.conf_*
+
+</VirtualHost>

+ 17 - 0
install/deb/templates/mail/apache2/disabled.tpl

@@ -0,0 +1,17 @@
+<VirtualHost %ip%:%web_port%>
+    ServerName %domain_idn%
+    ServerAlias %alias%
+    Alias / /var/lib/roundcube/
+    Alias /error/ %home%/%user%/web/%root_domain%/document_errors/
+    #SuexecUserGroup %user% %group%
+    
+    SSLEngine on
+    SSLVerifyClient none
+    
+    <Directory /var/www/html>
+        Options +FollowSymLinks
+        AllowOverride All
+        order allow,deny
+        allow from all
+    </Directory>
+</VirtualHost>

+ 33 - 0
install/deb/templates/mail/nginx/default_disabled.stpl

@@ -0,0 +1,33 @@
+server {
+    listen      %ip%:%proxy_ssl_port% ssl http2;
+    server_name %domain_idn% %alias_idn%;
+    root        /var/lib/roundcube;
+    index       index.php index.html index.htm;
+    access_log /var/log/nginx/domains/%domain%.log combined;
+    error_log  /var/log/nginx/domains/%domain%.error.log error;
+
+    ssl_certificate     %ssl_pem%;
+    ssl_certificate_key %ssl_key%;
+    ssl_stapling on;
+    ssl_stapling_verify on;
+
+    location ~ /\.(?!well-known\/) {
+        deny all;
+        return 404;
+    }
+
+    location / {
+        try_files $uri $uri/ =404;
+        alias /var/www/html;
+    }
+
+    location /error/ {
+        alias /var/www/document_errors/;
+    }
+	
+    location @fallback {
+        proxy_pass https://%ip%:%web_ssl_port%;
+    }
+
+    include %home%/%user%/conf/mail/%root_domain%/%proxy_system%.conf_*;
+}

+ 33 - 0
install/deb/templates/mail/nginx/default_disabled.tpl

@@ -0,0 +1,33 @@
+server {
+    listen      %ip%:%proxy_ssl_port% ssl http2;
+    server_name %domain_idn% %alias_idn%;
+    root        /var/lib/roundcube;
+    index       index.php index.html index.htm;
+    access_log /var/log/nginx/domains/%domain%.log combined;
+    error_log  /var/log/nginx/domains/%domain%.error.log error;
+    
+    ssl_certificate     %ssl_pem%;
+    ssl_certificate_key %ssl_key%;
+    ssl_stapling on;
+    ssl_stapling_verify on;
+    
+    location ~ /\.(?!well-known\/) {
+        deny all;
+        return 404;
+    }
+    
+    location / {
+        try_files $uri $uri/ =404;
+        alias /var/www/html;
+    }
+    
+    location /error/ {
+        alias /var/www/document_errors/;
+    }
+    
+    location @fallback {
+        proxy_pass https://%ip%:%web_ssl_port%;
+    }
+    
+    include %home%/%user%/conf/mail/%root_domain%/%proxy_system%.conf_*;
+}

+ 30 - 0
install/deb/templates/mail/nginx/disabled.stpl

@@ -0,0 +1,30 @@
+server {
+    listen      %ip%:%web_ssl_port% ssl http2;
+    server_name %domain_idn% %alias_idn%;
+    root        /var/www/html;
+    index       index.php index.html index.htm;
+    access_log /var/log/nginx/domains/%domain%.log combined;
+    error_log  /var/log/nginx/domains/%domain%.error.log error;
+
+    ssl_certificate     %ssl_pem%;
+    ssl_certificate_key %ssl_key%;
+    ssl_stapling on;
+    ssl_stapling_verify on;
+
+    location ~ /\.(?!well-known\/) {
+    deny all;
+    return 404;
+    }
+    
+    
+    location / {
+    try_files $uri $uri/ =404;
+    }
+    
+    location /error/ {
+    alias /var/www/document_errors/;
+    }
+
+
+    include %home%/%user%/conf/mail/%root_domain%/%web_system%.conf_*;
+}

+ 26 - 0
install/deb/templates/mail/nginx/disabled.tpl

@@ -0,0 +1,26 @@
+server {
+    listen      %ip%:%web_port%;
+    server_name %domain_idn% %alias_idn%;
+    root        /var/www/html;
+    index       index.php index.html index.htm;
+    access_log /var/log/nginx/domains/%domain%.log combined;
+    error_log  /var/log/nginx/domains/%domain%.error.log error;
+
+    include %home%/%user%/conf/mail/%root_domain%/nginx.forcessl.conf*;
+
+    location ~ /\.(?!well-known\/) {
+        deny all;
+        return 404;
+    }
+
+
+    location / {
+        try_files $uri $uri/ =404;
+    }
+
+    location /error/ {
+        alias /var/www/document_errors/;
+    }
+	
+    include %home%/%user%/conf/mail/%root_domain%/%web_system%.conf_*;
+}

+ 2 - 2
web/templates/pages/add_mail.html

@@ -93,13 +93,13 @@
 										<select class="vst-list" name="v_webmail" tabindex="6">
 											<?php foreach ($webmail_clients as $client){
 												echo "\t\t\t\t<option value=\"".htmlentities($client)."\"";
-												if ((!empty($v_webmail)) && ( $v_webmail == $client )) {
+												if (( $v_webmail == $client )) {
 													echo ' selected' ;
 												}
 												echo ">".htmlentities(ucfirst($client))."</option>\n";
 												}
 											?>
-											<option value="" <?php if(empty($v_webmail)){ echo "selected";}?>><?=_('Disabled');?></option>
+											<option value="" <?php if (empty($v_webmail) || $v_webmail == 'disabled' ){ echo "selected";}?>><?=_('Disabled');?></option>
 										</select>
 									</td>
 								</tr>

+ 2 - 2
web/templates/pages/edit_mail.html

@@ -76,13 +76,13 @@
 								<select class="vst-list" name="v_webmail" tabindex="6">
 									<?php foreach ($webmail_clients as $client){
 										echo "\t\t\t\t<option value=\"".htmlentities($client)."\"";
-										if ((!empty($v_webmail)) && ( $v_webmail == $client )) {
+										if (( $v_webmail == $client )) {
 											echo ' selected' ;
 										}
 										echo ">".htmlentities(ucfirst($client))."</option>\n";
 										}
 									?>
-									<option value="" <?php if (empty($v_webmail)){ echo "selected";}?>><?=_('Disabled');?></option>
+									<option value="disabled" <?php if ( empty($v_webmail) || ($v_webmail == 'disabled')) { echo "selected";}?>><?=_('Disabled');?></option>
 								</select>
 							</td>
 						</tr>