chore: initial commit of ai site platform

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
whm
2026-07-31 10:19:22 +08:00
commit 6366859bb3
222 changed files with 47313 additions and 0 deletions

53
nginx/README.md Normal file
View File

@@ -0,0 +1,53 @@
# Nginx 与可热重载配置Linux Docker 部署)
AI 建站默认用 **Docker web 容器**`127.0.0.1:5173`)对外提供页面,并在容器内把 `/api/``/ai/` 反代到 gateway。
若需 **独立域名 + HTTPS**(与同机 yh_web 并存),用 **宿主机 Nginx** 反代到 `5173`,不要与宇恒抢同一 `server_name`
## 配置文件映射(改完可只 reload / 单容器 restart
| 用途 | 仓库路径 | 生效方式 |
|------|----------|----------|
| 容器 Web 反代 | `web/nginx.conf` | `./reload-config.sh web` |
| Platform | `platform/etc/platform.docker.yaml` | `./reload-config.sh platform` |
| Gateway | `gateway/etc/gateway.docker.yaml` | `./reload-config.sh gateway` |
| LLM / 视觉 | `.env` | `./reload-config.sh ai` |
| 供应商与模型 | `ai-service/etc/llm.yaml` | `./reload-config.sh ai` |
| 宿主机域名 HTTPS | `nginx/aijz.host.conf``/etc/nginx/conf.d/` | `./reload-config.sh host-nginx` |
| SSL 证书 | `nginx/<域名>.pem` + `.key``/etc/ssl/aijianzhan/<域名>/` | `./reload-config.sh host-nginx` |
| 域名验证文件 | `verify-root/` | `./reload-config.sh host-nginx` |
| 前端静态 | `web/dist/` | 覆盖文件即可,无需重启 |
## 启用宿主机 Nginx可选
`.env` 中:
```bash
AIJZ_DOMAIN=aijz.example.com
AIJZ_ENABLE_HOST_NGINX=1
AIJZ_PUBLIC_BASE_URL=https://aijz.example.com
```
证书可放在项目 `nginx/` 下(与 yh_web 相同命名习惯):
- `nginx/aijz.example.com.pem` + `nginx/aijz.example.com.key`
-`nginx/fullchain.pem` + `nginx/privkey.pem`
然后:
```bash
./start.sh # 或 ./restart.sh会自动同步证书并生成 /etc/nginx/conf.d/<域名>.conf
./reload-config.sh host-nginx # 仅改 Nginx/证书/verify-root 时
```
## 常用命令
```bash
./reload-config.sh # 全部轻量重载(不 rebuild、不重建 dist
./reload-config.sh web # 容器 nginx -s reload
./reload-config.sh platform # 只 restart platform读新 yaml
./reload-config.sh gateway # 只 restart gateway
./reload-config.sh host-nginx # nginx -t && systemctl reload nginx
```
整栈重建仍用 `./restart.sh``./pull-and-restart.sh`

52
nginx/aijz.host.conf Normal file
View File

@@ -0,0 +1,52 @@
# 宿主机 Nginx443 终止 TLS反代到本机 Docker web127.0.0.1:5173
# web 容器内 nginx 已把 /api/、/ai/、/gateway/ 转发到 gateway。
#
# 占位符(由 scripts/lib-aijz-deploy.sh 替换):
# __DOMAIN__ 站点域名
# __WEB_PORT__ 宿主机 web 映射端口(默认 5173
# __VERIFY_ROOT__ 域名验证文件目录(项目 verify-root/
#
# 手动部署:
# 1. 证书放到 /etc/ssl/aijianzhan/__DOMAIN__/{fullchain.pem,privkey.pem}
# 2. sudo cp 生成后的 conf 到 /etc/nginx/conf.d/
# 3. sudo nginx -t && sudo systemctl reload nginx
server {
listen 80;
listen [::]:80;
server_name __DOMAIN__;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name __DOMAIN__;
client_max_body_size 128m;
ssl_certificate /etc/ssl/aijianzhan/__DOMAIN__/fullchain.pem;
ssl_certificate_key /etc/ssl/aijianzhan/__DOMAIN__/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_protocols TLSv1.2 TLSv1.3;
location ~ ^/[A-Za-z0-9._-]+\.(txt|html|xml)$ {
root __VERIFY_ROOT__;
try_files $uri =404;
default_type text/plain;
add_header Cache-Control "no-store";
}
location / {
proxy_pass http://127.0.0.1:__WEB_PORT__;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 300s;
proxy_send_timeout 300s;
}
}