docs(README): 更新项目文档并添加部署指南
- 在 README.md 中添加了详细的项目结构、快速开始、使用指南、开发指南等内容 - 新增生产环境部署步骤,包括前端和后端的构建
This commit is contained in:
10
docker/caddy/Caddyfile
Normal file
10
docker/caddy/Caddyfile
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
主配置文件,在/config目录
|
||||
|
||||
{
|
||||
# 全局选项:可关掉自动 HTTPS(测试环境)
|
||||
# auto_https off
|
||||
|
||||
}
|
||||
# 自动引入子配置
|
||||
import sites-enabled/*.caddy
|
||||
56
docker/caddy/biji-houdaun.caddy
Normal file
56
docker/caddy/biji-houdaun.caddy
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
反向代理,后端的反向代理,在/config/caddy.d目录下
|
||||
|
||||
|
||||
xxx.com { # 你的域名
|
||||
|
||||
# 处理预检请求
|
||||
@options method OPTIONS
|
||||
handle @options {
|
||||
header Access-Control-Allow-Origin "*"
|
||||
header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, PATCH, OPTIONS"
|
||||
header Access-Control-Allow-Headers "Content-Type, Authorization"
|
||||
header Access-Control-Allow-Credentials "true"
|
||||
header Access-Control-Max-Age "3600"
|
||||
respond "" 204
|
||||
}
|
||||
|
||||
# 为实际请求添加CORS头部
|
||||
header {
|
||||
Access-Control-Allow-Origin "*"
|
||||
Access-Control-Allow-Credentials "true"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# 反向代理到Gitea服务器的IP和端口
|
||||
reverse_proxy http://ip:8084 { #若是后端与caddy在同一个网络,可以直接指定后端的容器名
|
||||
|
||||
|
||||
# 移除后端返回的 CORS 头(防止冲突)
|
||||
header_down -Access-Control-Allow-Origin
|
||||
header_down -Access-Control-Allow-Methods
|
||||
header_down -Access-Control-Allow-Headers
|
||||
|
||||
|
||||
|
||||
# 传递原始客户端信息
|
||||
header_up X-Real-IP {remote_host}
|
||||
header_up X-Forwarded-For {remote}
|
||||
header_up X-Forwarded-Proto {scheme}
|
||||
|
||||
# 保持连接活跃(提高性能)
|
||||
transport http {
|
||||
keepalive 30s
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# 添加安全头部
|
||||
header {
|
||||
X-Frame-Options "DENY"
|
||||
X-Content-Type-Options "nosniff"
|
||||
Referrer-Policy "no-referrer-when-downgrade"
|
||||
}
|
||||
|
||||
}
|
||||
24
docker/caddy/biji-qianduan.caddy
Normal file
24
docker/caddy/biji-qianduan.caddy
Normal file
@@ -0,0 +1,24 @@
|
||||
前端页面部署,在/config/caddy.d目录下
|
||||
|
||||
xxx.com { # 你的前端域名
|
||||
root * /usr/share/caddy
|
||||
|
||||
# 静态资源:JS、CSS、图片等缓存 1 年
|
||||
@static {
|
||||
path *.js *.css *.png *.jpg *.jpeg *.gif *.ico *.svg *.woff *.woff2
|
||||
}
|
||||
header @static Cache-Control "public, max-age=259200, immutable"
|
||||
|
||||
# HTML 文件不缓存
|
||||
@html {
|
||||
path *.html
|
||||
}
|
||||
header @html Cache-Control "no-cache, no-store, must-revalidate"
|
||||
|
||||
# 静态文件需要的
|
||||
file_server
|
||||
|
||||
|
||||
# 也可以直接在这里反向代理后端
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user