Recently I updated my Plesk server from v12.5 to Onyx v17. I had setup many custom configurations for SSL related matters like smtp/imap/pop and webmail. After upgrading to Onyx I found out that all of these custom configurations were not needed any more because everything could be configured from the plesk panel!
The way I had setup things was redirect webmail for all domains to the webmail of my central domain for which I had installed an SSL certificate (and also my hosting logo!). So this way everyone would only use an https site to login to their emails. I could not find an option to do this in Onyx panel but I found the “proper” way to do it so that my configs would never be overwritten!
What you have to do is create a custom template, copy the webmail template and change it according to your needs.
Disclaimer: Everything I say is valid for CentOS server and I can not be sure if all is true for other distributions!
Before setting up the redirect you have to setup SSL for a webmail!
Go to your domains list in plesk panel and select the domain that you will use for webmail.
Choose “SSL/TLS certificates”, select an avaiable certificate (or upload a new one) and press “Secure Webmail”
Now create the custom webmail template folder (if it does not already exist)
cd /usr/local/psa/admin/conf/templates/
mkdir -p custom/webmail
Copy the default webmail config file
cd custom/webmail
cp -a ../../default/webmail/webmail.php
Edit this file to add your redirect (I added below lines immediately after “UseCanonicalName Off”)
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/ [NC]
RewriteRule (.*) https://webmail.EXAMPLE.COM/
You can have each domain redirect to each own https site by using this rewrite rule instead of specific domain (last line above)
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
After saving this file you have to apply it for all your domains by using this command
/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
Ready! Enjoy your https protected webmail!
Sources:
https://kb.plesk.com/en/129260
https://kb.plesk.com/en/123648