Files
photography/Caddyfile
xujiang 23e154aec1 fix: 修复 Caddy 权限问题和路径配置
- 修复 Caddyfile 中的路径问题,使用绝对路径 /home/gitea/www/photography
- 创建权限修复脚本 fix-caddy-permissions.sh
- 设置正确的目录权限让 caddy 用户可以访问 gitea 用户目录
- 更新部署文档,添加权限修复步骤和故障排除指南

修复内容:
-  使用绝对路径替代 ~ 路径
-  设置目录权限 755 让 caddy 用户可访问
-  添加权限检查和修复脚本
-  完善故障排除文档

现在应该能解决 "permission denied" 错误
2025-07-09 10:05:13 +08:00

60 lines
1.4 KiB
Caddyfile

# 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
}
}