@@ -128,9 +128,12 @@ if [ ! -z "$DNS_SYSTEM" ] && [ "$dkim" = 'yes' ]; then
fi
# Add webmail configuration to mail domain
-if [ ! -z "$WEB_SYSTEM" ]; then
- add_webmail_config "$WEB_SYSTEM" "default.tpl"
+WEBMAIL_TEMPLATE="proxy_system"
+if [ "$WEB_SYSTEM" = "nginx" ]; then
+ WEBMAIL_TEMPLATE="web_system"
+add_webmail_config "$WEB_SYSTEM" "${WEBMAIL_TEMPLATE}.tpl"
+
if [ ! -z "$PROXY_SYSTEM" ]; then
add_webmail_config "$PROXY_SYSTEM" "default.tpl"
@@ -64,9 +64,12 @@ is_web_domain_cert_valid
add_mail_ssl_config
- add_webmail_config "$WEB_SYSTEM" "default.stpl"
+add_webmail_config "$WEB_SYSTEM" "${WEBMAIL_TEMPLATE}.stpl"
add_webmail_config "$PROXY_SYSTEM" "default.stpl"
@@ -55,18 +55,20 @@ is_object_unsuspended 'mail' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Enable SSL for webmail if available
if [ -f $HOMEDIR/$user/conf/mail/$domain/ssl/$domain.crt ] || [ "$SSL" = 'yes' ]; then
- if [ ! -z "$WEB_SYSTEM" ]; then
- fi
+ add_webmail_config "$WEB_SYSTEM" "${WEBMAIL_TEMPLATE}.stpl"
@@ -671,7 +671,7 @@ del_mail_ssl_certificates(){
add_webmail_config() {
mkdir -p "$HOMEDIR/$user/conf/mail/$domain"
conf="$HOMEDIR/$user/conf/mail/$domain/$1.conf"
- if [ "$2" = "default.stpl" ]; then
+ if [[ "$2" =~ stpl$ ]]; then
conf="$HOMEDIR/$user/conf/mail/$domain/$1.ssl.conf"
@@ -716,19 +716,7 @@ add_webmail_config() {
chown root:$user $conf
chmod 640 $conf
- if [ "$2" = "default.tpl" ]; then
- rm -f /etc/$1/conf.d/domains/$WEBMAIL_ALIAS.$domain.conf
- ln -s $conf /etc/$1/conf.d/domains/$WEBMAIL_ALIAS.$domain.conf
- if [ ! -z "$PROXY_SYSTEM" ]; then
- # Clear old configurations
- rm -rf $HOMEDIR/$user/conf/mail/$domain.*
if [ ! -z "$WEB_SYSTEM" ]; then
forcessl="$HOMEDIR/$user/conf/mail/$domain/$WEB_SYSTEM.forcessl.conf"
rm -f /etc/$1/conf.d/domains/$WEBMAIL_ALIAS.$domain.ssl.conf
@@ -741,7 +729,7 @@ add_webmail_config() {
# Add rewrite rules to force HTTPS/SSL connections
+ if [ ! -z "$PROXY_SYSTEM" ] || [ "$WEB_SYSTEM" = 'nginx' ]; then
echo 'return 301 https://$server_name$request_uri;' > $forcessl
else
echo 'RewriteEngine On' > $forcessl
@@ -752,6 +740,17 @@ add_webmail_config() {
rm -rf $HOMEDIR/$user/conf/mail/$domain.*
rm -rf $HOMEDIR/$user/conf/mail/ssl.$domain.*
rm -rf $HOMEDIR/$user/conf/mail/*nginx.$domain.*
+ else
+ if [ ! -z "$WEB_SYSTEM" ]; then
+ rm -f /etc/$1/conf.d/domains/$WEBMAIL_ALIAS.$domain.conf
+ ln -s $conf /etc/$1/conf.d/domains/$WEBMAIL_ALIAS.$domain.conf
+ fi
+ if [ ! -z "$PROXY_SYSTEM" ]; then
+ # Clear old configurations
+ rm -rf $HOMEDIR/$user/conf/mail/$domain.*
}
@@ -0,0 +1,54 @@
+server {
+ listen %ip%:%web_ssl_port% ssl http2;
+ server_name %domain% %alias%;
+ root /var/lib/roundcube;
+ index index.php;
+ ssl_certificate %ssl_pem%;
+ ssl_certificate_key %ssl_key%;
+ error_log /var/log/%web_system%/domains/%domain%.error.log error;
+ location / {
+ try_files $uri $uri/ /index.php?$args;
+ location ~* ^.+\.(jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm)$ {
+ alias /var/lib/roundcube/;
+ expires 15m;
+ }
+ location /error/ {
+ alias %home%/%user%/web/%root_domain%/document_errors/;
+ location ~ /(config|temp|logs) {
+ return 404;
+ location /Microsoft-Server-ActiveSync {
+ alias /usr/share/z-push/;
+ location ~ ^/Microsoft-Server-ActiveSync/(.*\.php)$ {
+ alias /usr/share/z-push/$1;
+ fastcgi_pass 127.0.0.1:9000;
+ fastcgi_index index.php;
+ include fastcgi_params;
+ fastcgi_param SCRIPT_FILENAME $request_filename;
+ location ~ ^/(.*\.php)$ {
+ alias /var/lib/roundcube/$1;
+ location ~ /\.ht {return 404;}
+ location ~ /\.svn/ {return 404;}
+ location ~ /\.git/ {return 404;}
+ location ~ /\.hg/ {return 404;}
+ location ~ /\.bzr/ {return 404;}
+ include %home%/%user%/conf/mail/%root_domain%/%web_system%.ssl.conf_*;
+}
@@ -0,0 +1,52 @@
+ listen %ip%:%web_port%;
+ include %home%/%user%/conf/mail/%root_domain%/nginx.forcessl.conf*;
+ include %home%/%user%/conf/mail/%root_domain%/%web_system%.conf_*;