Nginx-Virtualmin virtual server template

I want to edit nginx server template. I want every new virtual server created to use some specific nginx server configs and location settings.

I want to add this line each time virtualmin created a server:

 if (!-f $request_filename) {
                    rewrite ^/(.*)$ /index.php?q=$1 last;

Where can i find it? or what is the best way to add these line automatic ?

Yes, I would also like to know the location of the nginx template.

I am setting up a server on which I want to deploy multiple virtual servers with Wordpress automatically installed via customized script installer (with a set of plugins and themes already loaded).

Wordpress requires a few tweaks to nginx.conf, and also has a local nginx.conf for each virtual server (created by W3 Total Cache plugin).

Therefore, it would be helpful to add these changes to the nginx template, similar to the way we can change the base php.ini to be a template for the virtual servers’ local php.ini’s.

The file you need to edit is:


I wrote up a quick how to on adding WordPress permalinks directly to this file so they’re added when a new Virtual Host is created

For info, on my server (Centos) its in the folder /usr/libexec/webmin/virtualmin-nginx

Be great to have it added to the Default Settings section in Server Templates. I need to add a LOT of new lines for Expression Engine, and seems quite tricky editing the file directly.