How to make Plesk accessible on the hostname without entering port?

Created:

2016-11-16 13:13:44 UTC

Modified:

2017-08-16 15:39:46 UTC

8

Was this article helpful?


Have more questions?

Submit a request

How to make Plesk accessible on the hostname without entering port?

Applicable to:

  • Plesk for Linux

Question

How to make Plesk accessible on the hostname without entering the port number?

Answer

1.    Go to Plesk and create a subscription with the required domain name. Let it be example.com
2.    Go to Websites & Domains > Hosting Settings and turn off PHP support & FastCGI support .
3.    For Plesk Onyx only: go to Apache & nginx settings screen and turn off 'Proxy mode' checkbox and click Apply .
4.    Scroll down till 'Additional nginx directives' and add the following lines:

For Plesk Onyx:

     location / {
proxy_pass https://example.com:8443; 
port_in_redirect off;
}

For Plesk 12.5:

     location ~^/ {
proxy_pass https://example.com:8443; 
port_in_redirect off;
}

5. Click Ok button to save the changes (it’s important to do step 3 & 4 separately).

The example.com address should be resolvable from the Plesk server. If not, the corresponding record should be added to /etc/hosts file. In order to do it, please follow this steps:

1. Log in to the server via SSH .

2. The corresponding record should be added to /etc/hosts file:

# echo "127.0.0.1 example.com" >> /etc/hosts
Have more questions? Submit a request

12 Comments

  • 0
    Avatar
    valery frisch

    hi,

    I try add the additional nginx directive but it's not working, this is the error message : 

    Configuration Nginx non valide : nginx: [emerg] duplicate location "/" in /data/www/system/console.valactive.com/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed

     

    What can i do to resolve this error?

    thanx

  • 0
    Avatar
    Lev Iurev

    @Valery check additional directives for the domain console.valactive.com, according to the error the issue is there

  • 0
    Avatar
    Grímur Daníelsson

    I'm using Plesk Onyx v17.5.3_build1705170317.16 os_CentOS 7 and the steps are a little different, the firewall is a Plesk component not an extension, so make sure the component is enabled.

    But my main problem is that I'm unable to login after following these steps. The login page is displayed correctly but when I login i get redirected to the login page like I haven't logged in at all.

    EDIT: It was a browser problem for me. Works when I try it in incognito

    Edited by Grímur Daníelsson
  • 0
    Avatar
    Marat

    just in case someone is having same error like me or valery frisch:
    "Configuration Nginx non valide : nginx: [emerg] duplicate location "/" in /data/www/system/this.domain.com/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed"

    while "this.domain.com" is the domain where you want to enable proxy for plesk panel, you have to disable prosy and apply settings before adding "additional nginx directives" and then save configuration with additional directives again.

  • 0
    Avatar
    Webmaster

    Worked fine, but when I click "Updates & Upgrades" it redirects me to https://127.0.0.1:8447/?secret=&locale=en-US. How to fix this?

  • 0
    Avatar
    Lev Iurev

    @Webmaster unfortunatelly it does not work for "Updates & Upgrades" as it is listening on another port. 

  • 0
    Avatar
    Webmaster

    Thanks, Lev! When I type in my new Plesk hostname before the port 'plesk.mydomain.com:8447...' it works just fine. Would that be possible to make the Upades&Upgrades redirect relative to the hostname then, not the localhost? Hiding a port number for the updates will, of course, not be possible but still better than typing in a custom hostname every time.

    On the other note, I have noticed that proxying port 80 to 8880 or 8443 opens the port for everyone on the Internet. I suggest blocking that with nginx: 

    location / {

        if ($remote_addr = 0.0.0.0) {
            proxy_pass https://127.0.0.1:8443;
        }
        if ($remote_addr != 0.0.0.0) {
            return 404;
        }

    }
  • 0
    Avatar
    Thomas

    @Lev lurev Do you have a more detailed explanation as to why this happens? I used this method and it works fine for the Plesk login. However, I do have the same redirect problem as @Webmaster when trying to reach the "Updates & Upgrades" page.

    After the redirect fails I can change 127.0.0.1 back to sub.domain.ext and reach the page, so it does still work.

    Is there any way to fix the redirect so it doesn't change the host name initially and redirects to https://sub.domain.ext:8447?

  • 0
    Avatar
    Robert Asilbekov

    @Webmaster I suppose that it will be better to restrict access via allow/deny

     

    location / {

    allow 192.168.1.0/24;
    # drop rest of the world
    deny all;

    proxy_pass ...

    }
    Edited by Robert Asilbekov
  • 0
    Avatar
    Webmaster

    @Robert, even better since nginx conditional statements are in a rudimental state so far! Thanks!

  • 0
    Avatar
    Derek

    Unable to find the last step:
    What do I do?

  • 0
    Avatar
    Lev Iurev

    @Derek  Additional nginx directives option available only for Plesk Admin.

Please sign in to leave a comment.