HestiaCP Nginx Template Generator
Create custom .tpl and .stpl web templates for HestiaCP — reverse proxy for Node.js, static sites, PHP apps and more.
Advertisement
Test Before Applying
Generated configuration is a starting point. Always:
- Test in a non-production environment
- Validate syntax before reloading services
- Keep a backup of your working config
- Adapt to your specific server setup
SysAdmin Tools provides this as a reference only and is not responsible for service interruptions.
# HestiaCP nginx HTTP template (.tpl) — generated by SysAdmin Tools
server {
listen %ip%:%web_port%;
server_name %domain_idn% %alias_idn%;
return 301 https://$host$request_uri;
}Install instructions
1. Save as /usr/local/hestia/data/templates/web/nginx/php-fpm/nodejs.tpl
2. Save the .stpl version in the same location
3. v-change-web-domain-tpl USER DOMAIN nodejs
4. nginx -t && systemctl reload nginx
Advertisement
Advertisement
This HestiaCP nginx template generator builds the .tpl (HTTP) and .stpl (HTTPS) web template files HestiaCP uses to render each domain's Nginx config. Create a reverse-proxy template for a Node.js or Next.js app, a static-site template, or a PHP template — complete with HestiaCP's %variable% placeholders — and drop them into the panel's template directory.
HestiaCP generates every domain's Nginx vhost from a named template, substituting variables like %ip%, %domain%, %web_port%, %ssl_pem% and %ssl_key% at render time. Writing a correct HestiaCP custom nginx template by hand means knowing which variables exist and keeping the .tpl and .stpl versions in sync. This HestiaCP template generator produces both files together so your HestiaCP nodejs template or reverse proxy works on the first apply.
Everything runs client-side. Generate the pair, save them under /usr/local/hestia/data/templates/web/nginx/, assign the template with v-change-web-domain-tpl, then test and reload Nginx.
How to Use the HestiaCP Template Generator
- 1
Choose a template type
Pick Reverse Proxy (for Node.js, Next.js and other app servers), Static Site, PHP App, or Custom. This decides the core location blocks generated.
- 2
Name the template
Give the template a short name such as nextjs or nodejs-3000. This becomes the .tpl/.stpl filename and the name you pass to v-change-web-domain-tpl.
- 3
Configure the proxy (if applicable)
For a reverse proxy, set the upstream port and host, enable WebSocket support, and set the read timeout so long requests are not cut off.
- 4
Toggle common and cache options
Enable HTTPS redirect, HSTS, gzip, access logging, custom error pages and long-lived static asset caching as needed. The HTTPS (.stpl) template includes the SSL certificate directives automatically.
- 5
Copy both files and apply
Copy the .tpl and .stpl tabs into the HestiaCP template directory, run v-change-web-domain-tpl for your user and domain, then nginx -t && systemctl reload nginx.
Understanding HestiaCP Nginx Templates
%variable% tokens with that domain's values. Templates live under /usr/local/hestia/data/templates/web/nginx/ (and the php-fpm/ subfolder for PHP-FPM templates). Each template is a pair: a .tpl file for the HTTP (port 80) vhost and a matching .stpl file for the HTTPS (port 443) vhost.
The two files are almost identical, differing mainly in the listen directive and the SSL block. The .stpl adds listen %ip%:%web_ssl_port% ssl; plus ssl_certificate %ssl_pem%; and ssl_certificate_key %ssl_key%; — HestiaCP fills those paths from the domain's installed certificate. Keeping the two in sync is essential, which is why this generator always emits both.
Common variables include %ip% (the server IP), %domain% and %domain_idn% (the domain, and its punycode form), %web_port% / %web_ssl_port% (the panel's configured HTTP/HTTPS ports), %user% (the account username, used in paths), %docroot% (the document root), and %sdocroot%. For a reverse proxy you add a location / with proxy_pass to your app's port and the standard proxy headers.| Field | Description |
|---|---|
| .tpl | The HTTP (port 80) template file HestiaCP renders into the non-SSL vhost. |
| .stpl | The HTTPS (port 443) template, identical to .tpl plus the SSL certificate directives. |
| %ip% | The server IP address the vhost listens on. |
| %domain% / %domain_idn% | The domain name and its IDN/punycode form for server_name. |
| %web_port% / %web_ssl_port% | The HTTP and HTTPS ports configured in the HestiaCP panel. |
| %docroot% | The document root path for the domain, e.g. /home/%user%/web/%domain%/public_html. |
| %ssl_pem% / %ssl_key% | Paths to the domain's certificate and private key, used only in the .stpl file. |
| %user% | The HestiaCP account username, used to build home-directory paths. |
Advertisement
Common HestiaCP Template Use Cases
Reverse proxy for Next.js / Node.js
Generate a proxy template that forwards to a Node.js app on 127.0.0.1:3000 with WebSocket upgrade headers, so HestiaCP serves your Next.js site behind Nginx with SSL.
Run multiple apps on one server
Create differently named templates (nodejs-3000, nodejs-4000) and assign each domain its own, letting one HestiaCP server front several app processes on different ports.
Custom PHP app template
Build a PHP template with a front-controller try_files rule and hidden-file protection for frameworks like Laravel, while keeping HestiaCP's managed PHP-FPM integration.
Harden a static site
Produce a static-site template with gzip, long-lived asset caching and security defaults, applied consistently across every static domain on the panel.
HestiaCP Nginx Template — Frequently Asked Questions
What is a HestiaCP nginx template?
How to create a custom HestiaCP template?
How to set up Node.js with HestiaCP?
What are .tpl and .stpl files in HestiaCP?
How to deploy Next.js on HestiaCP?
What HestiaCP template variables are available?
How to apply a custom template in HestiaCP?
How to create a reverse proxy in HestiaCP?
How to add HTTPS to a HestiaCP nginx template?
How to reload nginx after a template change?
Where exactly do the template files go?
Related Tools
Nginx Config Generator
Prototype the raw Nginx server block before turning it into a HestiaCP template.
n8n Docker Compose Generator
Self-host apps you can then front with a HestiaCP reverse-proxy template.
SSL Checker
Verify the certificate HestiaCP installs for your HTTPS template.
.htaccess Generator
Generate Apache rules if a domain uses the Apache backend instead.