Skip to content

security: add baseline security headers to nginx config#75

Merged
rubenhensen merged 1 commit into
mainfrom
security/nginx-headers
May 11, 2026
Merged

security: add baseline security headers to nginx config#75
rubenhensen merged 1 commit into
mainfrom
security/nginx-headers

Conversation

@dobby-coder
Copy link
Copy Markdown
Contributor

@dobby-coder dobby-coder Bot commented May 11, 2026

Summary

Adds the baseline HTTP security headers requested in #74 to nginx.conf:

  • Strict-Transport-Security: max-age=31536000; includeSubDomains
  • X-Content-Type-Options: nosniff
  • X-Frame-Options: DENY
  • Referrer-Policy: strict-origin-when-cross-origin
  • Content-Security-Policy: frame-ancestors 'none'

Headers are attached with always so they apply to error responses too. Because nginx add_header is replace-not-merge per location, the same block is repeated in the cache-control location (hashed assets) and /health. A more elaborate script-src / style-src CSP is left for a follow-up since VitePress and Mermaid use inline scripts and styles.

Closes #74.

Verification

  • npm run docs:build passes (6.95s, mermaid output intact).
  • Manual nginx syntax check via Docker was not possible in this environment; CI image build will exercise the config.

Reviewer quickstart:
git fetch origin && git checkout security/nginx-headers && docker build -t pgdocs-test . && docker run --rm -p 8080:80 pgdocs-test then curl -sI http://localhost:8080/ | grep -iE 'strict-transport|x-frame|x-content-type|referrer-policy|content-security-policy'.

Adds Strict-Transport-Security, X-Content-Type-Options, X-Frame-Options,
Referrer-Policy, and a minimal frame-ancestors Content-Security-Policy
to the server block. Headers are repeated in the cache-control and
/health locations because nginx add_header inheritance is
replace-not-merge per location.

Closes #74
@dobby-coder dobby-coder Bot marked this pull request as ready for review May 11, 2026 20:01
@dobby-coder dobby-coder Bot requested a review from rubenhensen May 11, 2026 20:01
@rubenhensen rubenhensen merged commit 070533d into main May 11, 2026
1 check passed
@rubenhensen rubenhensen deleted the security/nginx-headers branch May 11, 2026 20:02
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.

security: add baseline security headers to nginx config

1 participant