Plesk

How to enable/disable HTTPS redirection for webmail in Plesk for Linux

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:

Using SSL It! extension for a single domain

 

  1. Install the SSL It! extension.

  2. Secure webmail with an SSL certificate.

  3. Go to Domains > example.com > SSL/TLS Certificates >

  4. 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:

Disabling redirection to HTTPS via panel.ini for all domains

 

The HTTPS redirection for webmail can be disabled via Plesk configuration file panel.ini for all domains:

  1. Connect to a Plesk server via SSH.

  2. Open the file in an editor:

    # plesk conf panel.ini

    Add the following lines at the end of the file:

    [mail]
    webmail.forceHttp = true

  3. Save the changes and close the file.

 

Solution 3:

Creating a Plesk custom configuration template

 

  1. Connect to a Plesk server via SSH.

  2. Create a directory for custom configuration templates:

    # mkdir -p /usr/local/psa/admin/conf/templates/custom/webmail

  3. 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/

  4. 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]

  5. Save the changes and close the file.

  6. 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.

 

Creating a Plesk custom configuration template with Plesk Premium Email

 

  1. Connect to a Plesk server via SSH.

  2. 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]

  3. 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]

  4. Save the changes and close the file.

  5. 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…