# Nginx Templates

# Overview

Nginx templates allow you to customize the Nginx site configuration that Forge uses when creating your new site.

Broken Nginx Templates May Cause Downtime

Nginx templates that are not valid will prevent Nginx from properly working and your existing sites may stop responding. You should proceed with caution when creating and deploying custom Nginx templates.

# Creating Templates

You may create your own Nginx templates from within a server's management dashboard. When creating a new template, you need to provide a template name and the template's content. Forge will provide a default template that you may alter as required.

TLSv1.3

Although the default template does not show support for TLSv1.3, Forge will automatically update a site to support it if the server is able to do so.

# Template Variables

Forge provides several variables that can be used within your templates to dynamically alter their content for new sites:

Variable Description
The site's configured web directory, e.g. /public
The site's configured domains to respond to, e.g. laravel.com alias.laravel.com
The site's web accessible directory, e.g. /home/forge/laravel.com/public
The IPv4 port the site should listen to (:80). If the site name is default, this variable will also contain default_server
The IPV6 port to listen to ([::]:80). If the site name is default, this variable will also contain default_server
The PHP socket to listen on, e.g. unix:/var/run/php/php8.0-fpm.sock
The root of the configured site, e.g. /home/forge/laravel.com
The public IP address of the server
The private IP address of the server, if available
The site's name, e.g. laravel.com. This differs from in that it does not include site aliases.
The site's ID, e.g. 12345
The site's user, e.g. forge

When using these variables, you should ensure that they exactly match the syntax shown above.

# Managing Templates

You may edit the name and content of your Nginx template at any time. Changes to a template will not affect existing sites that use the template.

Deleting a template will not remove any sites which were configured to use it.