Create production-ready Nginx server blocks and Systemd files for Next.js and Django in a couple of clicks.
server {
listen %ip%:%proxy_port%;
server_name %domain_idn% %alias_idn%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
# Стандартный редирект на HTTPS HestiaCP
include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
location /.well-known/acme-challenge/ {
alias %home%/%user%/web/%domain%/public_html/.well-known/acme-challenge/;
try_files $uri =404;
}
# ОПТИМИЗИРОВАННЫЙ ПРОКСИ ДЛЯ САЙТМАПОВ (Next.js)
location ~ ^/sitemap.*\.xml$ {
proxy_pass http://127.0.0.1:3005;
proxy_set_header Host $http_host;
proxy_hide_header Content-Type;
proxy_hide_header Vary;
proxy_hide_header X-Powered-By;
proxy_hide_header X-Content-Type-Options;
proxy_hide_header X-Frame-Options;
add_header Content-Type "application/xml; charset=utf-8" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
proxy_cache_bypass $http_upgrade;
proxy_no_cache $http_upgrade;
gzip off;
proxy_read_timeout 60s;
}
location / {
proxy_pass http://127.0.0.1:3005;
proxy_set_header Host $http_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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
include %home%/%user%/conf/web/%domain%/nginx.conf_*;
}server {
listen %ip%:%proxy_ssl_port% ssl;
server_name %domain_idn% %alias_idn%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
ssl_stapling on;
ssl_stapling_verify on;
gzip on;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/javascript application/xml;
include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;
location /.well-known/acme-challenge/ {
alias %home%/%user%/web/%domain%/public_html/.well-known/acme-challenge/;
try_files $uri =404;
}
location ~ ^/sitemap.*\.xml$ {
proxy_pass http://127.0.0.1:3005;
proxy_set_header Host $http_host;
proxy_hide_header Content-Type;
proxy_hide_header Vary;
proxy_hide_header X-Powered-By;
add_header Content-Type "application/xml; charset=utf-8" always;
proxy_cache_bypass $http_upgrade;
proxy_no_cache $http_upgrade;
gzip off;
}
location /_next/static/ {
proxy_pass http://127.0.0.1:3005;
proxy_set_header Host $http_host;
expires 365d;
add_header Cache-Control "public, immutable";
}
location / {
proxy_pass http://127.0.0.1:3005;
proxy_set_header Host $http_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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
}/usr/local/hestia/data/templates/web/nginx/custom_app.tpl and custom_app.stpl respectively.Web → domain → Settings → Web Template Nginx → select custom_app.This tool helps generate perfect, secure Nginx configurations for Next.js and Django deployments. It automatically configures proxy_pass, surgically removes duplicate headers for sitemaps, configures static caching and creates ready-made templates for HestiaCP panel or bare Ubuntu servers.