• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion
  • Inviting everyone to the UX test of a new security feature in the WP Toolkit
    For WordPress site owners, threats posed by hackers are ever-present. Because of this, we are developing a new security feature for the WP Toolkit. If the topic of WordPress website security is relevant to you, we would be grateful if you could share your experience and help us test the usability of this feature. We invite you to join us for a 1-hour online session via Google Meet. Select a convenient meeting time with our friendly UX staff here.

Plesk 12 Webmail

KamalG

Basic Pleskian
Hello All,

My requirement is to redirect all hosted domain's webmail to the main hosting webmail url .. how can this be achieved ?

Kindly help
Thank you in advance.
 
Hi KamalG,

you could build custom templates at: "/usr/local/psa/admin/conf/templates/custom" for the default template files in: /usr/local/psa/admin/conf/templates/default/ and modify the two templates there.

domainWebmail.php and nginxWebmail.php

You have to modify the part
Code:
ServerAlias "webmail.<?php echo $VAR->domain->asciiName ?>"
<?php foreach ($VAR->domain->mailAliases AS $alias): ?>
    ServerAlias  "webmail.<?php echo $alias->asciiName ?>"
to your desired location and reconfigure all config files with the command:

/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
or
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain YOURDOMAIN.COM

Be sure, that the config - files at "/etc/apache2/plesk.conf.d/webmails/*" ( or your slightly different httpd - location instead of /etc/apache2/ !!! ) are all correct, after you recreated your config - files.
 
The nginxWebmail.php has the following code

Code:
<?php echo AUTOGENERATED_CONFIGS; ?>

<?php
/**
 * @var Template_VariableAccessor $VAR
 */
?>

<?php echo $VAR->includeTemplate('nginxWebmailPartial.php',
    array(
        'ssl' => true,
        'frontendPort' => $VAR->server->nginx->httpsPort,
        'backendPort' => $VAR->server->webserver->httpsPort,
    )) ?>

<?php echo $VAR->includeTemplate('nginxWebmailPartial.php',
    array(
        'ssl' => false,
        'frontendPort' => $VAR->server->nginx->httpPort,
        'backendPort' => $VAR->server->webserver->httpPort,
    )) ?>

Also how can I force https on webmail ?

Also making the custom configuration will let me redirect clients webmail to the default webmail ?

Please help.
 
Last edited:
If you set some "custom" templates, as suggested, then Plesk will primarily configure your server with the settings from the files of the folder "custom" instead of the "default" ones, located at "/usr/local/psa/admin/conf/templates/default". If there are no specific custom files, then the default files are used.

There are several options to force SSL on webmail - domains, depending on your environment ( apache only / apache + nginx / ... ). If you serve PHP - files over FastCGI and use nginx, you could copy the file "nginxWebmailPartial.php" from the default folder to the custom folder and add there for example under the ssl-protocol - section:

add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
 
Sir,

I did copy the files from /usr/local/psa/admin/conf/templates/default to /usr/local/psa/admin/conf/templates/custom and made the changes according to you..

only domainwebmail.php
has the code as you mentioned

Code:
ServerAlias "webmail.<?php echo $VAR->domain->asciiName ?>"
<?php foreach ($VAR->domain->mailAliases AS $alias): ?>
ServerAlias "webmail.<?php echo $alias->asciiName ?>"
[/B]

But not NginxWebmail.php instead it has

Code:
<?php echo AUTOGENERATED_CONFIGS; ?>

<?php
/**
* @var Template_VariableAccessor $VAR
*/
?>

<?php echo $VAR->includeTemplate('nginxWebmailPartial.php',
array(
'ssl' => true,
'frontendPort' => $VAR->server->nginx->httpsPort,
'backendPort' => $VAR->server->webserver->httpsPort,
)) ?>

<?php echo $VAR->includeTemplate('nginxWebmailPartial.php',
array(
'ssl' => false,
'frontendPort' => $VAR->server->nginx->httpPort,
'backendPort' => $VAR->server->webserver->httpPort,
)) ?>
[/B]

I already have the nginxWebmailPartial.php copied to custom folder and there is where I have set the SSL for the webmail main hosting domain..

Also enabling HSTS will force https on the webmail ?

I need more information Sir..
 
Hi mate,

here's part of a custom nginxWebmailPartial.php (starting line 9) I have used/am using

Code:
<?php if ($OPT['ssl']): ?>
  ssl_ecdh_curve  secp384r1;
  ssl_dhparam  /etc/ssl/dh4096.pem;
  ssl_certificate  /opt/psa/var/certificates/cert-name;
  ssl_certificate_key  /opt/psa/var/certificates/cert-name;
  ssl_client_certificate  /opt/psa/var/certificates/ca-name;
  ssl_session_timeout  5m;
  ssl_session_cache  shared:SSL:5m;
  ssl_prefer_server_ciphers  on;
  ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers  ECDHE-RSA-AES128-GCM-SHA256;  ## Shortened

  ssl_stapling on;
  ssl_stapling_verify on;
  ssl_trusted_certificate  /etc/ssl/certs/CA.pem; ## Intermediate + CA combined
  resolver 8.8.4.4 8.8.8.8 valid=300s;
  resolver_timeout 10s;

  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
<?php endif ?>

Note: I have included HSTS, OCSP, ECDH Curve and dhparam directives too.

You would need to put the http to https redirect in the horde.php and roundcube.php files to make sure any http connections get redirected.

Hope that helps
Kind regards

Lloyd
 
Back
Top