-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnginx.conf
More file actions
75 lines (67 loc) · 3.51 KB
/
nginx.conf
File metadata and controls
75 lines (67 loc) · 3.51 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# ╔══════════════════════════════════════════════════════════════╗
# ║ 🔐 Keyper – nginx SPA Server Config ║
# ╚══════════════════════════════════════════════════════════════╝
#
# Placed at /etc/nginx/conf.d/default.conf inside the container.
# Handles:
# • React SPA single-page routing (try_files fallback)
# • WebAssembly MIME type (required for argon2-browser)
# • Long-lived cache headers for immutable assets
# • Gzip compression
# • Hardened security headers
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# ── Compression ──────────────────────────────────────────────────────────
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_min_length 1024;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/javascript
application/json
application/xml
application/wasm
image/svg+xml
font/woff
font/woff2;
# ── Security headers ─────────────────────────────────────────────────────
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
# SharedArrayBuffer is required by argon2-browser WASM
add_header Cross-Origin-Embedder-Policy "require-corp" always;
# ── WebAssembly – correct MIME + cache ───────────────────────────────────
location ~* \.wasm$ {
default_type application/wasm;
expires 1y;
add_header Cache-Control "public, immutable";
}
# ── Immutable static assets ──────────────────────────────────────────────
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|otf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
# ── SPA fallback routing ─────────────────────────────────────────────────
# All unmatched paths serve index.html so React Router can handle routing
location / {
try_files $uri $uri/ /index.html =404;
}
# ── Health check endpoint ────────────────────────────────────────────────
location /healthz {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}