-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
104 lines (90 loc) · 2.68 KB
/
nginx.conf
File metadata and controls
104 lines (90 loc) · 2.68 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_comp_level 6;
gzip_types
text/plain
text/css
text/xml
text/javascript
text/markdown
application/javascript
application/json
application/xml+rss
application/atom+xml
image/svg+xml;
# Cache static assets aggressively
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|webp|avif)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
# Handle VitePress assets directory
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
# Serve markdown files (for source viewing)
location ~* \.md$ {
expires 1h;
add_header Cache-Control "public, must-revalidate";
add_header Content-Type "text/markdown; charset=utf-8";
}
# JSON files (search index, etc.)
location ~* \.json$ {
expires 1d;
add_header Cache-Control "public, must-revalidate";
add_header Content-Type "application/json; charset=utf-8";
}
# Main VitePress routing - simplified and more efficient
location / {
# VitePress clean URL handling
try_files $uri $uri.html $uri/ $uri/index.html /index.html;
# HTML files get proper caching
location ~* \.html$ {
expires 1h;
add_header Cache-Control "public, must-revalidate";
}
}
# Robots and sitemap
location = /robots.txt {
expires 1d;
add_header Cache-Control "public, must-revalidate";
}
location = /sitemap.xml {
expires 1d;
add_header Cache-Control "public, must-revalidate";
}
# Error pages
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
# Health check for CapRover
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
# CapRover identifier (if needed)
location /.well-known/captain-identifier {
return 200 "captain-identifier-file-content";
add_header Content-Type text/plain;
}
# Deny access to hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}