Question

I use Plesk and I have three domains and subdomains with different ngnix configs. At the moment I change the ngnix config in the /etc/ngnix/plesk.conf.d/vhost/manual after every update, because my changes are being overwritten by the httpdmng.

Now to my question; Can I create a separate template in /usr/local/psa/admin/conf/templates/folder for each domain?

Example: mydomain1 use the template from /usr/local/psa/admin/conf/templates/mydomain1/nginxDomainVirtualHost.php

mydomain2 use the template from /usr/local/psa/admin/conf/templates/mydomain2/nginxDomainVirtualHost.php

Was it helpful?

Solution 2

Plesk really shouldn't have its core edited. When you need domain level config changes there's a file you need to edit outside that file. Under Apache that file was called vhost.conf under the directory for your domain. It would then append that to the base config. It looks like nginx uses a similar process.

Based on this post here's what you need to do

Here steps how to add custom include in nginx virtual host config:

mkdir /usr/local/psa/admin/conf/templates/custom/domain

cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/

add in /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php:

 <?php if (file_exists($VAR->domain->physicalHosting->vhostDir . '/conf/nginx.conf')): ?> 
 include <?php echo $VAR->domain->physicalHosting->vhostDir;?>/conf/nginx.conf; 
 <?php endif ?>

/usr/local/psa/admin/bin/httpdmng --reconfigure-all # to apply new configuration for all domains

As result, if domain has conf/nginx.conf - it will be included into virtual host config.

OTHER TIPS

In case someone come across this post, for plesk 12 you just create vhost_nginx.conf in the /var/www/vhost/DOMAINE_NAME/conf/ directory and then run /usr/local/psa/admin/bin/httpdmng to get the file included in last_nginx.conf

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top