Sandbox
Run a published Webstir app behind nginx with the template API server via Docker Compose. Use this to validate dist/ outputs and production routing without the dev server.
Overview
- Two containers:
web(nginx) andapi(Node server). - Clean URLs: nginx maps
/about→/pages/about/index.htmland page assets. - API proxy: browser calls
http://localhost:8000directly to the API container. - Volumes mount published assets from your local build.
Files:
- Compose —
Sandbox/docker-compose.yml - nginx site config —
Sandbox/web/nginx.conf - nginx main config (loads Brotli modules) —
Sandbox/web/nginx.main.conf - custom nginx image (builds
ngx_brotli) —Sandbox/web/Dockerfile
Prerequisites
- Docker and Docker Compose installed.
- Published frontend and compiled backend available locally:
- Frontend:
dist/frontend/**(fromwebstir publish) - Backend:
build/backend/index.js(fromwebstir buildorwatch)
- Frontend:
The provided compose mounts a seed output under ../CLI/out/seed/.... Swap to your project paths as needed.
Usage
- From
Sandbox/run:docker compose up --build -d - Open:
http://localhost:8080(web) andhttp://localhost:8000(api) - Logs:
docker compose logs -f webordocker compose logs -f api - Stop:
docker compose down
Volumes & Paths
Default mounts (see compose):
- Web root:
../CLI/out/seed/dist/frontend→/usr/share/nginx/html - App assets:
../CLI/out/seed/dist/frontend/app→/usr/share/nginx/html/app - API app root:
../CLI/out/seed→/app(runsbuild/backend/index.js)
To use your project, point volumes at your project’s dist/frontend and built backend directory.
Nginx Behavior
- Clean URLs:
/servespages/home/index.html;/aboutservespages/about/index.html. - Page assets:
/index.*.(css|js)map topages/home/*;/about/*map topages/about/*. - Hashed assets: content‑hashed filenames receive
Cache-Control: public, max-age=31536000, immutable. - HTML:
no-cache, no-store, must-revalidate. - Compression: dynamic Brotli/gzip enabled; also serves precompressed
.brwhen present. - Security headers: CSP and standard security headers are set.
- Source maps: blocked in sandbox (404) to mirror production policy.
Environment
API container env (edit in compose if needed):
PORT=8000WEB_SERVER_URL=http://webAPI_SERVER_URL=http://api:8000
Expected Dist Layout
Produced by webstir publish (content‑hash fingerprinting):
dist/frontend/pages/<page>/index.htmldist/frontend/pages/<page>/index.<hash>.cssdist/frontend/pages/<page>/index.<hash>.jsdist/frontend/pages/<page>/manifest.json- Shared app assets under
dist/frontend/app/*
Troubleshooting
- 404s for pages: ensure
dist/frontend/pages/<page>/index.htmlexists and volumes point to the correctdistpath. - 404s for assets: verify fingerprinted files exist and nginx mapping matches page name.
- API not reachable: check
apilogs and thatbuild/backend/index.jsexists in the mounted directory. - Caching issues: hard refresh; nginx caches static assets for 7 days by default.