Skip to main content

Default and Custom Templates

Vhost Templates and App Templates

Cpnginx provides a user-friendly vhost template management system, which will allow you to create and maintain any type of virtualhost templates or app templates for your domains.

Customizing the global default templates.

Cpnginx uses the template language Python Mako. So it is easy to understand the template language.

Hybrid:  The default template file of hybrid mode is located on /etc/cpnginx/templates/vhost/hybrid.conf

To create a custom hybrid template, simply copy the file to the custom directory as follows:

cp /etc/cpnginx/templates/vhost/hybrid.conf /etc/cpnginx/templates/vhost/custom/hybrid.conf

Now you can edit this custom file and add your template options. This will be automatically used at the time of vhost configuration build.

Proxy:  The default template file of proxy mode is located in /etc/cpnginx/templates/vhost/proxy.conf

To create a custom proxy template, copy this file to the custom directory as follows

cp /etc/cpnginx/templates/vhost/proxy.conf /etc/cpnginx/templates/vhost/custom/proxy.conf

Now you can edit this custom file and add your template options. This will be automatically used at the time of vhost configuration build.

Nginx:  The default template file of nginx mode is located in /etc/cpnginx/templates/vhost/nginx.conf

To create a custom proxy template, copy this file to the custom directory as follows:

cp /etc/cpnginx/templates/vhost/nginx.conf /etc/cpnginx/templates/vhost/custom/nginx.conf

Now you can edit this custom file and add your template options. This will be automatically used at the time of vhost configuration build.

Template with a different name

You can build a template with a different name. Suppose if you are going to make a template called mytemplate based on the nginx template file, then do it as follows:

cp /etc/cpnginx/templates/vhost/nginx.conf /etc/cpnginx/templates/vhost/custom/mytemplate.conf

After that, edit the file mytemplate.conf and customize it as you wish. You can set this template as the default template for a domain.

After creating a custom template or app template, you need to rebuild the vhost template database. So that you and your cPanel users can choose this template from the user interface. To rebuild the template database, run the following command or use the rebuild options from whm interface.

nginxctl templaterebuild