Plesk – have a custom nginx.conf per Virtual Host

Update: Plesk 12, just create a file called vhost_nginx.conf in the /conf/ directory. No need for the below hack:

just like you can have a custom vhost.conf and vhost_ssl.conf for apache, here’s how to add this feature for nginx on plesk as well:

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

add this to the very end of the file

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

now you can create a file called conf/nginx.conf under the plesk virtual host and when running

# /usr/local/psa/admin/bin/httpdmng --reconfigure-all

it will include this file when generating the nginx reverse proxy configuration for each domain.

solution from here:

note: when using the plesk migration manager it will copy across this “nginxDomainVirtualHost.php” file but it will not copy across the domain specific nginx.conf files

1 thought on “Plesk – have a custom nginx.conf per Virtual Host

  1. Paul Hudson

    You might want to include your nginx config into the custom template directory itself so it’s included in migrations:

    Something like this:

    includeTemplate(‘domain/nginxcustom/nginxcustom.conf’, $OPT); ?>

    Any thoughts?


Leave a Reply to Paul Hudson Cancel reply

Your email address will not be published. Required fields are marked *