How to redirect Plesk 8443 port to a safe URL

Users coming from cPanel are used to access their account via the /cpanel and/or /whm URLs. Unfortunately Plesk’s login method is to access port 8443 which posts an invalid, self-signed, SSL certificate. As a result clients/visitors are usually scared to access such links, as all modern browsers block invalid SSL certificates by default or post big warnings.

The most easy fix is, as of this writing, to redirect port 8443 to Plesk hostname, which normally provides a valid SSL certificate and doesn’t uses a non-standard port. The client/visitor should simply access the /plesk URL and get redirected to wherever necessary. Also this helps providers redirect /cpanel and /whm to the new URL, pointing legacy users to the right place.

Here are the necessary steps:

1. Create a new custom/domain directory:

mkdir -p /usr/local/psa/admin/conf/templates/custom/domain

2. Copy domainVirtualHost.php from default to the custom directory:

cp /usr/local/psa/admin/conf/templates/default/domain/domainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/

3. Edit domainVirtualHost.php in the new location:

nano -w /usr/local/psa/admin/conf/templates/custom/domain/domainVirtualHost.php

4. Search for UseCanonicalName Off. Currently this is at line 35 in Plesk Obsidian, but this might obviously change in the future.

5. Remove UseCanonicalName Off and replace it with the following code:

<?php if ($VAR->domain->previewDomainName): ?>
    ServerAlias "<?php echo $VAR->domain->previewDomainName ?>"
<?php endif; ?>
UseCanonicalName Off
Redirect 301 /plesk https://your-new-plesk-hostname.tld
Redirect 301 /cpanel https://your-new-plesk-hostname.tld
Redirect 301 /whm https://your-new-plesk-hostname.tld

Replace https://your-new-plesk-hostname.tld with your Plesk’s server hostname, or any other location you might find suitable (WHMCS, billing platform etc).

You can redirect visitors to the Plesk’s hostname by using this code:

<?php if ($VAR->domain->previewDomainName): ?>
    ServerAlias "<?php echo $VAR->domain->previewDomainName ?>"
<?php endif; ?>
UseCanonicalName Off
Redirect 301 /plesk "https://<?php echo $VAR->server->fullHostName ?>"
Redirect 301 /cpanel "https://<?php echo $VAR->server->fullHostName ?>"
Redirect 301 /whm "https://<?php echo $VAR->server->fullHostName ?>"

6. Rebuild your configuration files. Please note that all the websites will be offline while the rebuild is taking place.

plesk repair web -y

That’s it! Now all clients/visitors can access Plesk by using their own https://domain.tld/plesk. Same goes with /cpanel and /whm legacy users.

Was this tutorial useful? Buy me a drink by using the “Donate” button below. :)

Leave a Comment

Your email address will not be published. Required fields are marked *