Articles in this section

How to redirect users to secure Plesk URL on port 8443

Plesk for Windows kb: how-to Plesk for Linux

Applicable to:

  • Plesk for Linux
  • Plesk for Windows

Question

How to redirect users to secure Plesk login page on port 8443?

For example, when a user opens https://203.0.113.2:8443 or http://203.0.113.2:8880, the page will be redirected to secured https://hostname.com:8443.

Answer

For Plesk on Linux
  1. Connect to your Plesk server via SSH.
  2. Create file /etc/sw-cp-server/conf.d/redirect_to_ssl.inc:

    # touch /etc/sw-cp-server/conf.d/redirect_to_ssl.inc

  3. Open it in a text editor. In this example, we are using vi editor:

    # vi /etc/sw-cp-server/conf.d/redirect_to_ssl.inc

  4. Add the following lines to the file:

    CONFIG_TEXT: if ($host ~ '203.0.113.2'){
        rewrite ^/(.*)$ https://hostname.com:8443/$1 permanent;
    }

    where

    • 203.0.113.2 - is your server's IP address
    • hostname.com - is your server's hostname, to which users will be redirected
  5. Save the changes and close the file.
  6. Restart Plesk services to apply changes:

    # service sw-cp-server restart && service sw-engine restart

 

 

To redirect users from all hosted domains, which are accessed via port 8443, to secure Plesk login page on port 8443, follow these steps:

Note: If the domains have HTTP Strict Transport Security (HSTS) enabled, disable it before applying the steps below.

  1. Connect to your Plesk server via SSH.
  2. Create file /etc/sw-cp-server/conf.d/redirect_to_ssl.inc:

    # touch /etc/sw-cp-server/conf.d/redirect_to_ssl.inc

  3. Open it in a text editor. In this example, we are using vi editor:

    # vi /etc/sw-cp-server/conf.d/redirect_to_ssl.inc

  4. Add the following lines to the file:

    CONFIG_TEXT: if ($host !~ 'hostname.com|127.0.0.1|localhost'){
        rewrite ^/(.*)$ https://hostname.com:8443/$1 permanent;
    }

    where

    • hostname.com - is your server's hostname, to which users will be redirected
  5. Save the changes and close the file.
  6. Restart Plesk services to apply changes:

    # service sw-cp-server restart && service sw-engine restart

 

For Plesk on Windows Server
  1. Connect to your Plesk server via RDP.
  2. Open the file web.config, which is located in %plesk_dir%admin\htdocs (by default C:\Program Files (x86)\Plesk\admin\htdocs) in a text editor.
  3. Find this section:

    CONFIG_TEXT: <configuration>
       <system.webServer>
           <rewrite>
               <rules>

  4. Right under the <rules> section, add the following lines:

    CONFIG_TEXT: <rule name="Redirect with port" enabled="true" stopProcessing="true">
        <match url=".*" />
        <conditions logicalGrouping="MatchAny">
            <add input="{HTTP_HOST}" pattern="^203.0.113.2:8880$" />
            <add input="{HTTP_HOST}" pattern="^203.0.113.2:8443$" />
        </conditions>
        <action type="Redirect" url="https://hostname.com:8443/{R:0}" />
    </rule>

    where

    • 203.0.113.2 - is your server's IP address
    • hostname.com - is your server's hostname, to which users will be redirected
  5. Save the changes and close the file.

 

Additional Information

Was this article helpful?

Comments

1 comment
Date Votes
  • for this to work, filename needs to be  redirect_to_ssl_plesk.inc  

    configuration file /etc/sw-cp-server/conf.d/plesk.confdynamically includes include conf.d/*plesk.inc;

    1

Please sign in to leave a comment.