fix(security): security headers and /.well-known/security.txt in nginx

Merged
EV
3d ago
+35-0

What

docs.traduora.co sent none of Content-Security-Policy / X-Frame-Options / Referrer-Policy / Permissions-Policy, its Server header carried the nginx version, and /.well-known/security.txt was a 404 (audit 2026-11-20, website security sweep).

This adds to the nginx server block:

  • add_header ... always (so 301s and 404s get them too): X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin, X-Frame-Options: SAMEORIGIN, Content-Security-Policy: base-uri 'self'; object-src 'none'; frame-ancestors 'self', Permissions-Policy: camera=(), geolocation=(), microphone=(). Same baseline as ever.co and the other Ever websites. No HSTS here: the Cloudflare zone sends it.
  • server_tokens off;
  • location = /.well-known/security.txt answered by nginx itself (RFC 9116, text/plain; charset=utf-8): Contact security@ever.co, Expires 2027-11-19, Canonical https://docs.traduora.co/.well-known/security.txt, Policy https://github.com/ever-co/ever-traduora/security/policy. It does not depend on Docusaurus copying a dot-directory out of static/, and an exact-match location cannot be shadowed by a built file. It sets no add_header, so it inherits the server-level set.
  • The asset location sets its own Cache-Control add_header, which drops the inherited ones in nginx, so it repeats the five headers.
  • absolute_redirect off;: nginx's directory redirect downgraded to http (https://docs.traduora.co/docs -> 301 http://docs.traduora.co/docs/, measured live). A relative Location keeps the client on https (same fix the other docs sites already have).
    Everything else (absolute_redirect, error pages, redirects) is unchanged.

How it was checked

nginx -t and curl against nginx:alpine (1.31.9) in a throwaway ci-builds pod with a stub site: /, a doc page, the slash-less 301, a CSS asset, an .html file, a 404, the redirects and /.well-known/security.txt all answer with the five headers and Server: nginx (no version); security.txt is 200 text/plain; charset=utf-8 with the fields above. After the merge the image build and the live site get the same checks.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes docs.traduora.co's nginx config: adds the ever.co baseline security headers, hides the nginx version, serves /.well-known/security.txt per RFC 9116, and fixes a directory redirect that downgraded https to http.

  • Server-level headers use always so 301s and 404s carry them too; no HSTS because the Cloudflare zone sends it.
  • The asset location repeats the headers because its Cache-Control add_header overrides inherited ones.
  • /.well-known/security.txt is answered by nginx itself, so it doesn't rely on the Docusaurus build copying dot-files.
  • absolute_redirect off emits a relative Location so redirects keep the client on https.
  • server_tokens off drops the nginx version from the Server header and error pages.