-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaddyfile
More file actions
81 lines (65 loc) · 1.9 KB
/
Caddyfile
File metadata and controls
81 lines (65 loc) · 1.9 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
# Global options
{
# Disable admin API (not needed for static sites)
admin off
# Use HTTP/2 and HTTP/3
servers {
protocols h1 h2 h3
}
}
:8080 {
# Health check endpoint
respond /health 200 {
body "{\"status\":\"ok\"}"
close
}
# Serve static files from the current directory
root * {$ROOT_PATH:.}
# Enable file server
file_server {
index index.html
}
# Handle errors with 404.html
handle_errors {
rewrite * /404.html
file_server
}
# Security headers
header {
# Prevent clickjacking
X-Frame-Options "DENY"
# Prevent MIME type sniffing
X-Content-Type-Options "nosniff"
# XSS protection (legacy, but still useful)
X-XSS-Protection "1; mode=block"
# Referrer policy - don't leak URL (important since content is in hash)
Referrer-Policy "no-referrer"
# Permissions policy - disable unnecessary features
Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()"
# Content Security Policy
# - Allow inline styles (needed for syntax highlighting)
# - Allow cdn.jsdelivr.net for QR code library
# - Allow data: for generated images
Content-Security-Policy "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self' https://cdn.jsdelivr.net; frame-ancestors 'none'; base-uri 'self'; form-action 'self'"
# Remove server header
-Server
}
# Cache static assets aggressively (1 year)
@static {
path *.png *.ico *.json
}
header @static Cache-Control "public, max-age=31536000, immutable"
# Cache HTML with revalidation (1 hour)
@html {
path *.html /
}
header @html Cache-Control "public, max-age=3600, must-revalidate"
# On-the-fly compression (zstd preferred, gzip fallback)
encode zstd gzip
# Logging (minimal, errors only)
log {
output stdout
format json
level ERROR
}
}