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:
24
README.md
24
README.md
@@ -105,20 +105,18 @@ caddy by Host header. Caddy stays the single router (apex landing, `auth.`
|
||||
-f docker-compose.static.yml -f docker-compose.distribution.yml up -d
|
||||
```
|
||||
|
||||
4. **Render + install the nginx vhost** from `nginx/ulicraft-caddy.conf.tmpl`.
|
||||
Substitute `CADDY_HTTP_PORT` (proxy target), `BASE_DOMAIN`, `APP_DIR` (repo
|
||||
path on the host, for the cert files):
|
||||
4. **Render + install the nginx vhost** with `tooling/render-nginx.sh`. It pulls
|
||||
`BASE_DOMAIN` + `CADDY_HTTP_PORT` from `.env`, defaults `APP_DIR` to the repo
|
||||
checkout (where `certs/` live), and renders `nginx/ulicraft-caddy.conf.tmpl`:
|
||||
```sh
|
||||
CADDY_HTTP_PORT=8880 BASE_DOMAIN=ulicraft.net APP_DIR=/home/ubuntu/mc/ulicraft-server-v1 \
|
||||
envsubst '$CADDY_HTTP_PORT $BASE_DOMAIN $APP_DIR' \
|
||||
< nginx/ulicraft-caddy.conf.tmpl | sudo tee /etc/nginx/sites-available/ulicraft.conf
|
||||
sudo ln -sf /etc/nginx/sites-available/ulicraft.conf /etc/nginx/sites-enabled/
|
||||
sudo nginx -t && sudo systemctl reload nginx
|
||||
tooling/render-nginx.sh # preview to stdout (dry run)
|
||||
tooling/render-nginx.sh --install # write, symlink, nginx -t, reload
|
||||
```
|
||||
Overrides via env: `APP_DIR=/path` (if the repo isn't at the cert location),
|
||||
`SITE_NAME=foo.conf`, `TEMPLATE=nginx/ulicraft.conf.tmpl` (the static variant —
|
||||
nginx serves the files itself + proxies only drasl; pick one, not both).
|
||||
|
||||
Re-run step 4 whenever you add a subdomain (e.g. a new vhost) so its server
|
||||
block is rendered. `nginx/ulicraft.conf.tmpl` is the older alternative (nginx
|
||||
serves the static files itself + proxies only drasl) — pick one, not both.
|
||||
Re-run step 4 whenever you add a subdomain so its server block is rendered.
|
||||
|
||||
`distribution.${BASE_DOMAIN}` serves a static site whose web root lives in
|
||||
another repo: set `DISTRIBUTION_WEB_ROOT` (absolute host path) in `.env`; it's
|
||||
@@ -146,8 +144,10 @@ dnsmasq/dnsmasq.conf.tmpl # optional DNS config (rendered)
|
||||
docker/avahi/ # mDNS responder image
|
||||
pack/ # packwiz modpack source
|
||||
landing/ # Astro site → www/
|
||||
tooling/ # build-stack, render-config, dns-records,
|
||||
tooling/ # build-stack, render-config, render-nginx,
|
||||
# dns-records, issue-letsencrypt,
|
||||
# mirror-mods, mirror-airgap, fetch-launcher
|
||||
nginx/*.conf.tmpl # host-nginx TLS vhost templates
|
||||
mirror/ # vendored jars + launcher + asset mirror (gitignored)
|
||||
plan/ # full design docs (00–12)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user