nginxwebserverpleskmediatemple

How can I setup default directives for all servers in nginx? (Issues with Plesk)


I have a DV 4.0 server on media temple which is setup with nginx as a reverse proxy to apache. I want to configure some far future expires headers (using location blocks) and other settings for my (multiple) domains running through nginx.

Normally this wouldn't be an issue, just create a common set of rules and include them in a server {} block. However, Plesk creates and updates the server {} blocks automatically in separate files, meaning any changes made in these files are wiped out.

Ideally I'd like a way to set up a generic server {} block that gets applied all servers as defaults, but if this doesn't exist I'd like to know how to add custom directives within Plesk so they don't get wiped out when it rewrites the files.


Solution

  • Check this page

    Yoг can customize default nginx virtual hosting template:

    1. mkdir /usr/local/psa/admin/conf/templates/custom/domain
    2. cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/
    3. add or change what you need in /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
    4. /usr/local/psa/admin/bin/httpdmng --reconfigure-all # to apply new configuration for all domains