Question
How to enable/disable HTTPS redirection (force webmail to use SSL) for webmail in Plesk for Linux?
Answer
A redirection in Webmail from HTTP to HTTPS on a Plesk for Linux server can be configured either via SSL It! extension, by creating a Plesk custom configuration template, modifying the webmail native configuration file or modifying the webmail .htaccess file:
Solution 1:
-
Go to Domains > example.com > SSL/TLS Certificates >
-
Under the Options, enable Redirect from HTTP to HTTPS > click Configure > select/deselect Apply to webmail > click on Update to apply the changes.
Solution 2:
The HTTPS redirection for webmail can be disabled via Plesk configuration file panel.ini for all domains:
-
Connect to a Plesk server via SSH.
-
Open the file in an editor:
# plesk conf panel.ini
Add the following lines at the end of the file:
[mail]
webmail.forceHttp = true -
Save the changes and close the file.
Solution 3:
-
Connect to a Plesk server via SSH.
-
Create a directory for custom configuration templates:
# mkdir -p /usr/local/psa/admin/conf/templates/custom/webmail
-
Copy the original file
webmail.php
to the created directory:# cp -p /usr/local/psa/admin/conf/templates/default/webmail/webmail.php /usr/local/psa/admin/conf/templates/custom/webmail/
-
Open the file
/usr/local/psa/admin/conf/templates/custom/webmail/webmail.php
in a text editor (for example, vi editor) and insert the records below right before the first </VirtualHost> string:RewriteEngine On
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA] -
Save the changes and close the file.
-
Regenerate configuration files for all domains:
Note: During this operation, the websites will be unavailable for a short period of time. The execution time of this command depends on the number of domains on the server.
# plesk sbin httpdmng --reconfigure-all
To disable this redirect, remove the
/usr/local/psa/admin/conf/templates/custom/webmail/webmail.php
file and repeat step 6.
-
Connect to a Plesk server via SSH.
-
Edit the custom configuration template
/usr/local/psa/admin/conf/templates/custom/webmail/roundcube.php
created by Plesk Premium Email and locate the following text:RewriteEngine On
RewriteRule ^/[a-zA-Z0-9]{16}/(.*) /$1 [PT,L] -
Add the following lines after the text block identified in the previous step:
RewriteEngine On
RewriteRule ^/[a-zA-Z0-9]{16}/(.*) /$1 [PT,L]
# Redirect Kolab from HTTP to HTTPS
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA] -
Save the changes and close the file.
-
Regenerate configuration files for all domains:
Note: During this operation, the websites will be unavailable for a short period of time. The execution time of this command depends on the number of domains on the server…