• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion
  • Please beaware of a breaking change in the REST API on the next Plesk release (18.0.62).
    Starting from Plesk Obsidian 18.0.62, requests to REST API containing the Content-Type header with a media-type directive other than “application/json” will result in the HTTP “415 Unsupported Media Type” client error response code. Read more here

Question Set http port 777 for subdomain

Bull Criss

New Pleskian
I have been searching the web for an answer to this question but I couldn't find anything.

I have a CentOs server managed with Plesk 12.5, with a 2nd level domain mysite.com for which I have created a number of subdomains (3rd level) sd1.mysite.com, sd2.mysite.com, etc.
The web server is Apache and also NGix is installed and working.

All the subdomains are reachable from the web : e.g. http://sd1.mysite.com, through port 80.

For one of these subdomains, I need it to be reachable through port 777, which means http://sd7.mysite.com:777

How can I achieve that by setting additional directives (Apache and/or NGix, like "listen"), for a specific subdomain, without affecting all the other ones ?

I hope my question is clear... Thank you in advance for your support!
 
@Bull Criss

In fact, the most easy method is to use Nginx.

In the subdomain, one would easily copy the various default entries, except for the fact that the ports 80 and 443 will be changed to port 777.

If I am not mistaken, you can simply

1) go to /etc/nginx/plesk.conf.d/vhosts

2) copy sub.domain.tld.conf file, use the command: cp -p sub.domain.tld.conf customsub.domain.tld.conf

Note: the name <customsub> can be replaced by any name of your choice.

3) edit the file customsub.domain.tld.conf and replace the port values 80 and 443 with the port value 777 (and that is all you have to do)

4) run a Nginx configuation test: nginx -t

5) restart Nginx: service nginx restart

and you should be done.

Note a number of important things:

a) the files sub.domain.tld.conf and customsub.domain.tld.conf can easily co-exist, so there is no problem there, except when a typo in the URL has been or will be made: any request to http://sd7.mysite.com will be served via port 80 (that is, if the file sub.domain.tld.conf has not been deleted),

b) removing the file sub.domain.tld.conf is possible, but not recommended (and this file will return sooner or later, due to the autogeneration of these files),

c) you might want to consider to do a simple redirection of traffic on ports 80 and 443, with the directive of the form

return 301 $scheme://customsub.domain.tld:777$request_uri;

and the above should be entered in the Plesk Panel in the part "Additional nginx directives" on the domain sub.domain.tld.


Hope the above helps a bit, you can surely give it a try.

Regards..........
 
thank you for your replies!

but....
1) go to /etc/nginx/plesk.conf.d/vhosts

2) copy sub.domain.tld.conf file, use the command: cp -p sub.domain.tld.conf customsub.domain.tld.conf
how do I do this? From the file manager of the domain mysite.com I see an "etc" folder but inside it I only have 3 files : group, passwd and resolv.conf...
 
@Bull Criss

You stated

how do I do this? From the file manager of the domain mysite.com I see an "etc" folder but inside it I only have 3 files : group, passwd and resolv.conf...

and the answer to your question is: via SSH.

However, what do you mean with "from the file manager..."? Which file manager??

It certainly is not a good idea that you can access the "passwd" file from any file manager, is there something strange or wrong with the hosting setup?
 
and the answer to your question is: via SSH.
I asked my hosting/server provider : looks like I won't do it because they say that if I access the server via SSH they will suspend their maintenance service.
I was hoping it was possible to do the port setting simply in the part "Additional nginx directives", but if that's not possible then I'll have to give up...
 
Back
Top