About Plesk URL or Telling Customers the Right Address to Go to

Introduction

A long time ago Plesk had one good little feature: when typing the panel address in your browser address bar, if you specified the port (8443), but omitted the encryption method (https), Plesk would redirect you to the address https://<server_hostname>:8443. In version 11.5, we replaced the lighttpd web server that served Plesk with nginx. And broke that good little feature.

Right away, our users pointed out that breaking good little features and giving nothing in return is bad. Please forgive and forget 🙂 As you can see in Plesk 12.0 preview (available through autoinstaller with –all-versions key), we returned the previous behavior.

What’s our point in telling this story? We wanted to share one interesting use-case proposed by our users and to contribute to it.

So, let’s assume that your server hostname is panel.provider.com and you installed a valid SSL certificate to protect Plesk. Now you tell your customer: “To enter the hosting control panel, add :8443 to your domain name. For example, example.com:8443.” After that, the customer is automagically redirected from http://example.com:8443 to https://panel.provider.com:8443 and kept out of a terrible error informing them about an SSL certificate issued to a domain other than theirs, an attempt to steal their data and other horror stories that browsers tell. The customer sees the green address bar in their browser and does not see any errors – the provider’s credibility grows.

How it works and what else can be done with it

The magic is hidden in the /etc/sw-cp-server/config configuration file, namely in the following string:

In case a plain HTTP request was sent to an HTTPS port, this string makes the web server (works only for nginx) redirect the user to the “correct” address. The correct address consists of the correct https protocol, the server hostname, port number and the remaining part of the “incorrect” request.

As many of you have already guessed it right, we can replace the $hostname variable with a definite address. Thus, we get rid of strict binding to the server hostname. Still, editing the configuration file is a very bad idea. Most likely, further Plesk updates will not install correctly, because the configuration file was changed. That’s why we are going to create a new file, where we simply redefine this instruction. We will create a /etc/sw-cp-server/conf.d/zzz-myhost.inc file with the following content:

Then restart sw-cp-server

Thus, all users will be directed to https://panel.provider.com:8443 regardless of the server hostname.

Cherry on Top

For those who do not like working with console or editing configuration files, we developed an extension that does this work for you. It will be especially useful for those who actively use Custom View and do not have an access to the server. The only limitation of this extension is that the settings are not applied automatically. You will have to restart the sw-cp-server service or the whole server.

Links

Showing 6 comments
  • Sebastian Beßler
    Reply

    I have found an error in the article.

    Instead of
    /etc/sw-cp-server/conf.d/zzz-myhost.conf
    a
    /etc/sw-cp-server/conf.d/zzz-myhost.inc
    has to be created.

    The extension does the right thing

  • Bart
    Reply

    Is there also a way to do this in a Plesk 12 Windows version?

    Many thanks,
    Bart

  • Alexander
    Reply

    Link to “Extension – custom-plesk-host” – broken.
    I tried to do this follow instructions on Plesk 12.0.18 #27, but no success.

  • Martin
    Reply

    the customer is automagically redirected from http://example.com:8443 to https://panel.provider.com:8443

    Yes, this is working, but if the customer is already on a secure connection and uses https://example.com:8443, then it does not redirect and the terrible error informing them about an SSL certificate issued to a domain other than theirs shows up instead.

    since the customer already is on a secure connection with example.com there is no http_error 497… which would redirect the customer to panel.provider.com:8443

    I tried this in plesk -> domain example.com -> apache&nginx-setting:

    RewriteEngine On
    RewriteCond %{SERVER_PORT} ^8443
    RewriteCond %{HTTP_HOST} ^example.com?(.*)$ [NC]
    RewriteRule ^(.*)$ https://panel.provider.com:8443/$1 [R=301,L]

    But it has no effect. If I put other more simple rewriterules there they work.
    This is driving me crazy…

    Is using RewriteRules even the right solution to this problem?

    Plesk v12.5.30_build1205150826.19 os_Ubuntu 14.04
    Ubuntu 14.04.1 LTS

    Any help is highly appreciated!

Leave a Comment