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
- Connect to your Plesk server via SSH.
-
Create file
/etc/sw-cp-server/conf.d/redirect_to_ssl.inc:# touch /etc/sw-cp-server/conf.d/redirect_to_ssl.inc
-
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
-
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
-
- Save the changes and close the file.
-
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.
- Connect to your Plesk server via SSH.
-
Create file
/etc/sw-cp-server/conf.d/redirect_to_ssl.inc:# touch /etc/sw-cp-server/conf.d/redirect_to_ssl.inc
-
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
-
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
-
- Save the changes and close the file.
-
Restart Plesk services to apply changes:
# service sw-cp-server restart && service sw-engine restart
- Connect to your Plesk server via RDP.
- Open the file
web.config, which is located in%plesk_dir%admin\htdocs(by defaultC:\Program Files (x86)\Plesk\admin\htdocs) in a text editor. -
Find this section:
CONFIG_TEXT: <configuration>
<system.webServer>
<rewrite>
<rules> -
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
-
- Save the changes and close the file.
Comments
for this to work, filename needs to be
redirect_to_ssl_plesk.incconfiguration file
/etc/sw-cp-server/conf.d/plesk.confdynamically includesinclude conf.d/*plesk.inc;Please sign in to leave a comment.