-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
85 lines (73 loc) · 2.52 KB
/
nginx.conf
File metadata and controls
85 lines (73 loc) · 2.52 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
76
77
78
79
80
81
82
83
84
85
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Gzip compression
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_min_length 256;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/json
application/javascript
application/xml
application/rss+xml
image/svg+xml;
# 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 Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: blob:; connect-src 'self'; worker-src 'self' blob:; manifest-src 'self';" always;
# Health check endpoint
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
# Service worker - never cache
location /sw.js {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
# PWA manifest - short cache
location /manifest.webmanifest {
add_header Cache-Control "no-cache, must-revalidate";
types { application/manifest+json webmanifest; }
}
# Workbox files - never cache
location ~* ^/workbox- {
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
# Hashed assets - immutable long cache
location /assets/ {
add_header Cache-Control "public, max-age=31536000, immutable";
}
# Translation files - moderate cache
location /locales/ {
add_header Cache-Control "public, max-age=3600, must-revalidate";
}
# Images - long cache
location ~* \.(png|jpg|jpeg|gif|svg|webp|ico)$ {
add_header Cache-Control "public, max-age=604800";
}
# Fonts - immutable long cache
location ~* \.(woff|woff2|ttf|eot)$ {
add_header Cache-Control "public, max-age=31536000, immutable";
}
# SPA fallback
location / {
try_files $uri $uri/ /index.html;
}
# Error handling
error_page 404 /index.html;
error_page 500 502 503 504 /index.html;
}