• 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

Resolved Changing domain vhost port for Apache and nginx in Plesk

s.kazimierczak

New Pleskian
Server operating system version
CentOS Linux 7.9.2009 (Core)
Plesk version and microupdate number
Obsidian 18.0.46 Update #2
Hi guys,
Is there a way to change the default port number for Apache and nginx in Plesk Additional Apache & nginx directives?
Changing this value in httpd.conf for vhost will be replaced with any change in Plesk. I want to only change the port for one website. I don't want to create custom templates because I don't want any future websites to use different ports than default ones.
Can anyone help?
Thanks in advance
 
this cannot be done

well, if I think a bit outside the box....
you could create an "Event Handler" in Plesk, that fires on domain updates and executes a shell script that does use something like awk/sed to search and replace the ports in the nginx and apache2 config file of this specific website and then reloads the nginx/apache2 service.
This way it would re-apply your custom ports again, any time you make some changes
 
Hi guys,
Is there a way to change the default port number for Apache and nginx in Plesk Additional Apache & nginx directives?
Changing this value in httpd.conf for vhost will be replaced with any change in Plesk. I want to only change the port for one website. I don't want to create custom templates because I don't want any future websites to use different ports than default ones.
Can anyone help?
Thanks in advance
Did you ever find a solution for this, needing to do something exactly like this?
 
This can be easily solved by a case switch in the template file, e.g. "if ... then".
Is there a way to do this when the domain is already added to Plesk. Or is there a way to change the current configuration for the reverse proxy set up where Apache uses 7081 and nginx uses 443 and change that to make nginx look for 3000 (as an example).
 
Never mind I figured out a solution:
Just went to the specific domain that I wanted changed and disabled nginx proxy mode and then under additional nginx directives in put the following

Code:
location / {
    proxy_pass https://my.ip.addr.here:3000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
 
Back
Top