Skip to content

fix(nginx): add HSTS to the security-headers block generator - #192

Merged
acamarata merged 1 commit into
mainfrom
fix/nginx-hsts-header
Jul 6, 2026
Merged

fix(nginx): add HSTS to the security-headers block generator#192
acamarata merged 1 commit into
mainfrom
fix/nginx-hsts-header

Conversation

@acamarata

Copy link
Copy Markdown
Collaborator

Summary

  • Adds Strict-Transport-Security: max-age=63072000; includeSubDomains to the shared securityHeaders nginx directive block in internal/nginx/generator.go, so every generated server block (api., ping., custom services) gets HSTS for free — per the Security-Always-Free doctrine.
  • Root cause: the weekly nself-org/web SSL Audit flagged api.nself.org for missing HSTS (grade A+, clean TLS otherwise) — confirmed genuine via live curl -sI, unlike the Vercel-fronted marketing domains which already set HSTS via vercel.json.
  • Rollout to the live 5.75.235.42 box requires a CLI upgrade (box is 3 minor versions behind at v0.9.9) — that surfaced its own config-validation/secret-regeneration differences and needs its own migration plan, tracked separately, not bundled into this fix.

Test plan

  • go build ./... succeeds
  • go test ./internal/nginx/... passes (includes updated TestSecurityHeadersConstant)

Every nginx-fronted subdomain (api.nself.org, ping.nself.org, any custom
service) was missing Strict-Transport-Security. The weekly SSL Audit
correctly flagged api.nself.org for it — testssl confirmed grade A+ and
clean TLS, but no HSTS header at all, unlike the Vercel-hosted marketing
sites which already set it via vercel.json.

Per the Security-Always-Free doctrine, hardening ships free and automatic
via the CLI's generated nginx config, not as an opt-in env var or a hand
edit to the gitignored generated output (which nself build would wipe on
the next run anyway). Adds
`Strict-Transport-Security: max-age=63072000; includeSubDomains` to the
shared securityHeaders const so it lands in every server{} block the
generator emits.

Rolling this out to the live 5.75.235.42 box requires a CLI release +
prod CLI upgrade (currently 3 minor versions behind at v0.9.9) and is
tracked separately — that upgrade surfaced its own config-validation and
secret-regeneration behavior differences that need their own migration
plan, not a same-day side effect of an SSL audit fix.
@acamarata
acamarata merged commit 89070de into main Jul 6, 2026
26 of 27 checks passed
@acamarata
acamarata deleted the fix/nginx-hsts-header branch July 6, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant