refactor: 清理根目录结构,重组部署文件
移动文件: - Caddyfile → docs/deployment/Caddyfile - fix-caddy-permissions.sh → docs/deployment/fix-caddy-permissions.sh 删除无用文件: - 根目录 package.json (空项目文件) - 根目录 bun.lock (无用锁定文件) - 根目录 node_modules/ (无用依赖目录) 保留文件: - lint-staged.config.js (项目级 pre-commit 配置) 更新引用: - 更新 caddy-setup.md 中的文件路径 - 更新 deployment/README.md 文档结构 现在根目录更干净,部署相关文件统一在 docs/deployment/ 目录下
This commit is contained in:
60
docs/deployment/Caddyfile
Normal file
60
docs/deployment/Caddyfile
Normal file
@ -0,0 +1,60 @@
|
||||
# Photography Portfolio Caddyfile
|
||||
# 将 https://photography.iriver.top 映射到用户目录
|
||||
|
||||
photography.iriver.top {
|
||||
# 静态文件服务
|
||||
root * /home/gitea/www/photography
|
||||
|
||||
# 启用文件服务器
|
||||
file_server
|
||||
|
||||
# 启用 gzip 压缩
|
||||
encode gzip
|
||||
|
||||
# 设置默认首页
|
||||
try_files {path} {path}/ /index.html
|
||||
|
||||
# 设置静态资源缓存
|
||||
@static {
|
||||
path *.css *.js *.png *.jpg *.jpeg *.gif *.svg *.woff *.woff2 *.ttf *.eot *.ico
|
||||
}
|
||||
header @static Cache-Control "public, max-age=31536000, immutable"
|
||||
|
||||
# 设置 HTML 文件缓存
|
||||
@html {
|
||||
path *.html
|
||||
}
|
||||
header @html Cache-Control "public, max-age=3600"
|
||||
|
||||
# 安全头设置
|
||||
header {
|
||||
# 防止点击劫持
|
||||
X-Frame-Options "SAMEORIGIN"
|
||||
# 防止 MIME 类型嗅探
|
||||
X-Content-Type-Options "nosniff"
|
||||
# XSS 保护
|
||||
X-XSS-Protection "1; mode=block"
|
||||
# 推荐 HTTPS
|
||||
Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
||||
# 隐藏服务器信息
|
||||
-Server
|
||||
}
|
||||
|
||||
# 日志配置
|
||||
log {
|
||||
output file /var/log/caddy/photography.log {
|
||||
roll_size 10MB
|
||||
roll_keep 5
|
||||
}
|
||||
format json
|
||||
}
|
||||
|
||||
# 错误页面处理
|
||||
handle_errors {
|
||||
@404 {
|
||||
expression {http.error.status_code} == 404
|
||||
}
|
||||
rewrite @404 /404.html
|
||||
file_server
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user