feat(nginx): render-nginx.sh + www->apex redirect vhost

Add tooling/render-nginx.sh: pulls BASE_DOMAIN/CADDY_HTTP_PORT from .env,
defaults APP_DIR to the repo checkout, renders a vhost template (default the
caddy-front one) to stdout, or --install writes + symlinks + nginx -t + reloads.
Document it in the README, replacing the manual envsubst one-liner.

Also add the www.${BASE_DOMAIN} canonical 301->apex block and put www in the
LE_SUBDOMAINS default so its cert is issued.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-09 01:09:46 +02:00
parent f3c38da56c
commit 3185fea4c1
5 changed files with 89 additions and 16 deletions

View File

@@ -32,7 +32,7 @@ upstream ulicraft_caddy {
server {
listen 80;
listen [::]:80;
server_name ${BASE_DOMAIN} auth.${BASE_DOMAIN} pack.${BASE_DOMAIN} distribution.${BASE_DOMAIN};
server_name ${BASE_DOMAIN} www.${BASE_DOMAIN} auth.${BASE_DOMAIN} pack.${BASE_DOMAIN} distribution.${BASE_DOMAIN};
return 301 https://$host$request_uri;
}
@@ -58,6 +58,18 @@ server {
}
}
# www -> apex canonical redirect (needs its own cert; covered by LE_SUBDOMAINS).
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.${BASE_DOMAIN};
ssl_certificate ${APP_DIR}/certs/www.${BASE_DOMAIN}/cert.pem;
ssl_certificate_key ${APP_DIR}/certs/www.${BASE_DOMAIN}/key.pem;
return 301 https://${BASE_DOMAIN}$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;