• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question How to open port for domain?

MrPleskLearner

Basic Pleskian
Server operating system version
Ubuntu 22.04
Plesk version and microupdate number
Plesk 18
Hi,

i want to open port for webpage.com:9007

What i did is, i just navigated to /etc/apache2/ports.conf and added Listen 9007 then restarted apache.

This opened the port for ip adress of server only. But on my server i have different webpages. So this didn't help for webpage.com:9007

Then i navigated in plesk to apache & nginx settings for webpage.com and in Additional directives i wanted to add Listen 9007 but then i got error message

1683387552796.png

Then i opened /var/www/vhosts/system/webpage.com/conf/vhost_ssl.conf and vhost.conf but nothing is inside of these files...

What should i do to open port for the webpages?
 
In default for example port 21 and 443 are open. I can navigate to website.com:443

But from where all these settings are coming from?

I checked the files under /usr/local/psa/admin/conf/templates/ but i could not find there something which allows for example ports 21 or 443 so that i can use the same settings for my wanted port 9007...

I am really confused how to "open" the port 9007...
 
You need to change the templates from which Plesk creates the web server configuration files so that the virtual host definitions listen to your port in addition to or instead of the existing ports.

For example in /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualhost.php you find the Nginx virtual host template that includes the "listen" directive. The current "listen" directive is
Code:
listen <?php echo $OPT['ipAddress']->escapedAddress . ':' . $OPT['frontendPort'] . ($OPT['ssl'] ? ' ssl' : ''); ?>;
but you want
Code:
listen <?php echo $OPT['ipAddress']->escapedAddress . ':9007' . ($OPT['ssl'] ? ' ssl' : ''); ?>;
This change however will not be enough. What you will want to do is to duplicate the existing server block and add the same, but with the 9007 port instead of the variable frontendPort. So you leave all content in the template as is, but append it with an extra server {...} block that serves port 9007 either with or without SSL (probably with SSL). As a template how that server block needs to look, you can use the existing SSL template section and only modify the port as shown in the example above. You end up with at least three server blocks in that nginx configuration template file.

For Apache this can be done in the /usr/local/psa/admin/conf/templates/default/domain/DomainVirtualhost.php file. You can also omit the nginx part if you want Apache to react on 9007 directly. In that case you only modify /usr/local/psa/admin/conf/templates/default/domain/DomainVirtualhost.php. Same procedure, just different content.

You must not tell both, nginx and Apache, to listen to port 9007. Either nginx or Apache, but never both. Maybe for your case it is better to only tell Apache to listen on 9007, because probably your software runs on "PHP-FPM via Apache", so your PHP requests will be processed by Apache and not Nginx.

Code:
<VirtualHost <?php echo $OPT['ipAddress']->escapedAddress ?>:<?php echo $OPT['ssl'] ? $VAR->server->webserver->httpsPort : $VAR->server->webserver->httpPort ?> <?php echo ($VAR->server->webserver->proxyActive && $OPT['ipAddress']->isIpV6()) ? "127.0.0.1:" . ($OPT['ssl'] ? $VAR->server->webserver->httpsPort : $VAR->server->webserver->httpPort) : ''; ?>>
needs to become
Code:
<VirtualHost <?php echo $OPT['ipAddress']->escapedAddress ?>:9007 <?php echo ($VAR->server->webserver->proxyActive && $OPT['ipAddress']->isIpV6()) ? "127.0.0.1:" . ($OPT['ssl'] ? $VAR->server->webserver->httpsPort : $VAR->server->webserver->httpPort) : ''; ?>>
 
Hello Peter!

i opened /usr/local/psa/admin/conf/templates/default/domain/DomainVirtualhost.php.

and changed

<VirtualHost <?php echo $OPT['ipAddress']->escapedAddress ?>:<?php echo $OPT['ssl'] ? $VAR->server->webserver->httpsPort : $VAR->server->webserver->httpPort ?> <?php echo ($VAR->server->webserver->proxyActive && $OPT['ipAddress']->isIpV6()) ? "127.0.0.1:" . ($OPT['ssl'] ? $VAR->server->webserver->httpsPort : $VAR->server->webserver->httpPort) : ''; ?>>

to

<VirtualHost <?php echo $OPT['ipAddress']->escapedAddress ?>:9007 <?php echo ($VAR->server->webserver->proxyActive && $OPT['ipAddress']->isIpV6()) ? "127.0.0.1:" . ($OPT['ssl'] ? $VAR->server->webserver->httpsPort : $VAR->server->webserver->httpPort) : ''; ?>>

then sudo service apache2 restart

But it didnt help. The php script still cannot connect to port 9007 and if i check if the port is open i see that it's closed

1683464646234.png

 
Back
Top