security: add baseline security headers to nginx config#75
Merged
Conversation
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
rubenhensen
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the baseline HTTP security headers requested in #74 to
nginx.conf:Strict-Transport-Security: max-age=31536000; includeSubDomainsX-Content-Type-Options: nosniffX-Frame-Options: DENYReferrer-Policy: strict-origin-when-cross-originContent-Security-Policy: frame-ancestors 'none'Headers are attached with
alwaysso they apply to error responses too. Because nginxadd_headeris replace-not-merge per location, the same block is repeated in the cache-control location (hashed assets) and/health. A more elaboratescript-src/style-srcCSP is left for a follow-up since VitePress and Mermaid use inline scripts and styles.Closes #74.
Verification
npm run docs:buildpasses (6.95s, mermaid output intact).Reviewer quickstart:
git fetch origin && git checkout security/nginx-headers && docker build -t pgdocs-test . && docker run --rm -p 8080:80 pgdocs-testthencurl -sI http://localhost:8080/ | grep -iE 'strict-transport|x-frame|x-content-type|referrer-policy|content-security-policy'.