User selectable Nginx templates (SKINS)

Version 1.61.6

Feature
Finished

This feature is part of the "DirectAdmin Pro Pack" https://docs.directadmin.com/getting-started/pro-pack/overview/ ==== New command: CMD_NGINX_TEMPLATES Feature allowing Users to select from pre-made templates to be inserted into the nginx server entries for common scripts like WordPress. List of templates can be managed through DA. This is a JSON-only feature (Enhanced will not have it, Evolution will have it) It will apply only to domains, and not to subdomains (similar to E-Mail accounts) Should you need an nginx template on a subdomain, create it as a full domain instead. ================================================== VIEW To view the list of nginx templates, and to view the current locations the domain: CMD_NGINX_TEMPLATES method: GET domain=domain.com OUTPUT (eg) { "locations": { "/wordpress": { "nginx_template": "wordpress_with_fastcgi_cache" } }, "templates": { "wordpress_with_fastcgi_cache": { "name": "WordPress", "path": "/etc/nginx/templates/wordpress_with_fastcgi_cache.conf" } } } ================================================== SAVE To set a given location to a template, run: CMD_NGINX_TEMPLATES method: POST domain=domain.com action=save location=/wordpress nginx_template=wordpress_with_fastcgi_cache ================================================== DELETE To clear a list of template locations: CMD_NGINX_TEMPLATES method: POST domain=domain.com action=delete select1=/wordpress (select2=/otherpath) ================================================== TOKENS Global token: HAVE_NGINX_TEMPLATES=yes|no if the feature is available in the current license. ================================================== TEMPLATES CustomBuild will manage the templates in: /etc/nginx/templates/*.conf The format of the template will be a standard nginx code to be inserted into an nginx location block. The first line of the template is a data line, and should contain something like this: #INFO=name=WordPress where everything after the #INFO= string is url-encoded, allowing for extra vars in the future. If you do not specify the name, DA will name it the name of the file, less .conf (wordpress_with_fastcgi_cache) Before the Include to this file, dA will set the $template_location variable to "/wordpress" (for example), which can be used in the Included template conf. location ~ ^(/wordpress)(/.*)?$ { set $template_location "$1/"; Include /etc/nginx/templates/wordpress_with_fastcgi_cache.conf; include /usr/local/directadmin/data/users/testuser/nginx_php.conf; } ================================================== DATA DirectAdmin will store the list of locations in: /usr/local/directadmin/data/users/USERNAME/domains/DOMAIN.COM.locations.json which is a json file, listing each location. each location is an array, and the sub-item that applies here would be the template name, eg: { "/wordpress" : { "nginx_template" : "wordpress_with_fastcgi_cache" } } as this leaves other options which could be set for that location in the future.

Interested to try DirectAdmin? Get a 30-day Free Trial!