Files
stpweb/nginx/security_headers.conf
T
adamfandClaude Code a3bf0b26e5
Deploy with Docker Compose / deploy (push) Successful in 47s
csp: allow wasm-unsafe-eval so Rust AutoScroll WASM loads
03e10be added a CSP to the SPA document; default-src 'self' without
'wasm-unsafe-eval' blocks WebAssembly.instantiateStreaming, killing the
wasm port of AutoScroll. Keyword permits wasm compilation only, not JS eval.

Co-Authored-By: Claude Code <[email protected]>
2026-09-22 23:26:16 +01:00

23 lines
1.5 KiB
Plaintext

# Included at every level that sets at least one of its own add_headers.
# nginx replaces a parent's whole add_header set inside any block that
# declares one of its own, so without this include, locations like /assets/
# and /sound/ silently lose every security header the server block sets.
# Locations that add extra headers of their own (the /uploads/ blocks) can
# include this AND their own lines; the include plus their own add_header
# directives merge additively.
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
# Applied to the main document; the /uploads/ blocks override with their own
# locked-down CSP by declaring Content-Security-Policy again themselves
# (a later add_header of the same name within one response wins).
# 'wasm-unsafe-eval' is needed for WebAssembly compilation (the Rust
# AutoScroll module, vue/crates/stp_wasm): without it script-src falls back
# to default-src 'self', which blocks WebAssembly.instantiateStreaming() in
# every modern browser. It allows wasm compilation only, not JS eval, so it
# is the narrowest keyword that unblocks the feature.
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; img-src 'self' data: https:; style-src 'self' 'unsafe-inline'; font-src 'self' data:; connect-src 'self'; frame-ancestors 'self'; base-uri 'self'; object-src 'none'" always;