-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathnginx.conf
More file actions
58 lines (52 loc) · 5.3 KB
/
Copy pathnginx.conf
File metadata and controls
58 lines (52 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# QNBS-v3: nginx only inherits a parent level's add_header directives when the current level has
# NONE of its own — a location block that sets even one add_header (e.g. Cache-Control below) drops
# every server-level add_header for requests matching it. Both asset-caching location blocks below
# therefore duplicate the security header lines explicitly rather than relying on inheritance.
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# QNBS-v3: SPA fallback — all non-asset routes serve index.html for client-side routing.
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets aggressively (Vite content-hashed filenames)
location ~* \.(js|css|woff2?|ttf|eot|svg|png|jpg|jpeg|gif|ico|webp)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
# QNBS-v3: duplicated — see the file-level note above on nginx's add_header inheritance rule.
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 Permissions-Policy "camera=(), microphone=(self), geolocation=()" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; font-src 'self' data:; img-src 'self' data: blob:; connect-src 'self' https://generativelanguage.googleapis.com https://api.openai.com https://api.x.ai https://api.anthropic.com https://openrouter.ai https://api.openrouter.ai https://api.groq.com https://huggingface.co https://us.aws.cdn.hf.co https://api.languagetool.org http://localhost:11434 http://127.0.0.1:11434 http://localhost:1234 http://127.0.0.1:1234 http://localhost:8000 http://127.0.0.1:8000 http://localhost:8010 http://127.0.0.1:8010 wss://y-webrtc-signaling.fly.dev wss://signaling.yjs.dev; worker-src 'self' blob:; frame-src 'self' blob:; manifest-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none';" always;
}
# Service worker must never be cached
location = /sw.js {
expires -1;
add_header Cache-Control "no-store, no-cache, must-revalidate";
# QNBS-v3: duplicated — see the file-level note above on nginx's add_header inheritance rule.
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 Permissions-Policy "camera=(), microphone=(self), geolocation=()" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; font-src 'self' data:; img-src 'self' data: blob:; connect-src 'self' https://generativelanguage.googleapis.com https://api.openai.com https://api.x.ai https://api.anthropic.com https://openrouter.ai https://api.openrouter.ai https://api.groq.com https://huggingface.co https://us.aws.cdn.hf.co https://api.languagetool.org http://localhost:11434 http://127.0.0.1:11434 http://localhost:1234 http://127.0.0.1:1234 http://localhost:8000 http://127.0.0.1:8000 http://localhost:8010 http://127.0.0.1:8010 wss://y-webrtc-signaling.fly.dev wss://signaling.yjs.dev; worker-src 'self' blob:; frame-src 'self' blob:; manifest-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none';" always;
}
# Security headers (server level — applies to `location /` and any other block without its own add_header)
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;
# QNBS-v3: microphone=(self), NOT (): Voice (hooks/useMicLevel.ts, hooks/useSpeechRecognition.ts)
# calls getUserMedia/SpeechRecognition from same-origin. An empty allowlist blocks that same-origin
# call too, so it silently kills Whisper STT, push-to-talk, and the mic-level meter on this host.
add_header Permissions-Policy "camera=(), microphone=(self), geolocation=()" always;
# QNBS-v3: mirrors the index.html meta CSP (ADR-0004) — keep both in sync, see docs/DEPLOYMENT.md
# "Header invariants per host" and tests/unit/csp.test.ts.
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; font-src 'self' data:; img-src 'self' data: blob:; connect-src 'self' https://generativelanguage.googleapis.com https://api.openai.com https://api.x.ai https://api.anthropic.com https://openrouter.ai https://api.openrouter.ai https://api.groq.com https://huggingface.co https://us.aws.cdn.hf.co https://api.languagetool.org http://localhost:11434 http://127.0.0.1:11434 http://localhost:1234 http://127.0.0.1:1234 http://localhost:8000 http://127.0.0.1:8000 http://localhost:8010 http://127.0.0.1:8010 wss://y-webrtc-signaling.fly.dev wss://signaling.yjs.dev; worker-src 'self' blob:; frame-src 'self' blob:; manifest-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none';" always;
# Gzip compression
gzip on;
gzip_types text/plain text/css application/javascript application/json image/svg+xml;
gzip_min_length 1024;
}