Skip to content

Instantly share code, notes, and snippets.

@rogeriotaques
Last active December 11, 2025 17:22
Show Gist options
  • Select an option

  • Save rogeriotaques/b082afc443d180abce1afc8a679ac4f7 to your computer and use it in GitHub Desktop.

Select an option

Save rogeriotaques/b082afc443d180abce1afc8a679ac4f7 to your computer and use it in GitHub Desktop.
HestiaCP NginX Templates : Single and multi-tenant NodeJS apps

HestiaCP NginX Templates

Have a VPS running HestiaCP which should run a single or multi tenant Nodejs application? These are the templates that are gonna help you set it up out of the box! These templates were designed to just work, specially if you're running your servers behind CloudFlare.

Installing the templates

Copy these files into /usr/local/hestia/data/templates/web/nginx/, restart Nginx and you should already see the templates listed in the Backend Template option in the Advanced Options on your domain settings page.

Content of this Gist

For multi tenant apps.

  • multitenant-nodejs.tpl
  • multitenant-nodejs.stpl

For single tenant apps.

  • nodejs.tpl
  • nodejs.stpl
# HestiaCP Web NginX Template
# /usr/local/hestia/data/templates/web/nginx/multitenant-nodejs.stpl
#
# This template creates a catch-all domain that enables a multi-tenant
# NodeJs app running on port :3000.
server {
listen %ip%:80 default_server;
server_name _;
return 301 https://%host%$request_uri;
}
server {
listen %ip%:443 ssl http2 default_server;
server_name _;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types image/svg+xml svg svgz text/plain application/x-javascript text/xml text/css;
gzip_vary on;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_pass http://127.0.0.1:3000;
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location ~ /\.ht { return 404; }
location ~ /\.svn/ { return 404; }
location ~ /\.git/ { return 404; }
location ~ /\.hg/ { return 404; }
location ~ /\.bzr/ { return 404; }
location ~ /\.db/ { return 404; }
location ~ /\.duckdb/ { return 404; }
location ~ /\.sqlite/ { return 404; }
}
# HestiaCP Web NginX Template
# /usr/local/hestia/data/templates/web/nginx/multitenant-nodejs.tpl
#
# This template creates a catch-all domain that enables a multi-tenant
# NodeJs app running on port :3000.
server {
listen %ip%:80 default_server;
server_name _;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_pass http://127.0.0.1:3000;
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location ~ /\.ht { return 404; }
location ~ /\.svn/ { return 404; }
location ~ /\.git/ { return 404; }
location ~ /\.hg/ { return 404; }
location ~ /\.bzr/ { return 404; }
location ~ /\.db/ { return 404; }
location ~ /\.sqlite/ { return 404; }
location ~ /\.duckdb/ { return 404; }
}
# HestiaCP Web NginX Template
# /usr/local/hestia/data/templates/web/nginx/nodejs.stpl
#
# This template enables a NodeJs app running on port :3000.
server {
listen %ip%:80;
server_name %domain_idn% %alias_idn%;
return 301 https://%domain_idn%$request_uri;
}
server {
listen %ip%:443 ssl http2;
server_name %domain_idn% %alias_idn%;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types image/svg+xml svg svgz text/plain application/x-javascript text/xml text/css;
gzip_vary on;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_pass http://127.0.0.1:3000;
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location ~ /\.ht { return 404; }
location ~ /\.svn/ { return 404; }
location ~ /\.git/ { return 404; }
location ~ /\.hg/ { return 404; }
location ~ /\.bzr/ { return 404; }
location ~ /\.db/ { return 404; }
location ~ /\.duckdb/ { return 404; }
location ~ /\.sqlite/ { return 404; }
}
# HestiaCP Web NginX Template
# /usr/local/hestia/data/templates/web/nginx/nodejs.tpl
#
# This template enables a NodeJs app running on port :3000.
server {
listen %ip%:80;
server_name %domain_idn% %alias_idn%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_pass http://127.0.0.1:3000;
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location ~ /\.ht { return 404; }
location ~ /\.svn/ { return 404; }
location ~ /\.git/ { return 404; }
location ~ /\.hg/ { return 404; }
location ~ /\.bzr/ { return 404; }
location ~ /\.db/ { return 404; }
location ~ /\.sqlite/ { return 404; }
location ~ /\.duckdb/ { return 404; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment