Question
On a Plesk for Linux server, it is required to configure a redirect to the Plesk login page on port 8443 from the Web Server's Default Page or website that exists in Plesk.
How can it be done?
Answer
Warning: Configuring the redirect will result in an inability to issue/renew Let's Encrypt certificate due to the Let's Encrypt requests are performed with ports 80/443
Configure a redirect from the Web Server's Default Page
-
Connect to the server via SSH
-
Create the file
/var/www/vhosts/default/htdocs/.htaccess
:# touch /var/www/vhosts/default/htdocs/.htaccess
-
Add the following content to it using text editor:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^203.0.113.2$
RewriteCond %{HTTP_HOST} ^203.0.113.3$
RewriteRule ^.*$ https://example.com:8443/ [R,L]
Redirect 301 / https://example.com:8443/Note: 203.0.113.2, 203.0.113.3 and example.com should be replaced with public IP addresses and hostname of the server respectively.
Configure a redirect from a domain that exists in Plesk
-
Go to Domains > example.org > Apache & nginx Settings
-
Add the following additional directives:
-
If the field Additional nginx directives is present, add the following content to it's beginning:
return 301 https://example.com:8443/;
-
If the field Additional nginx directives is absent, add the following content to both fields Additional directives for HTTP and Additional directives for HTTPS:
Redirect "/" "https://example.com:8443/"
Note: example.com should be replaced with the hostname of the server.
-