54 lines
2.2 KiB
Markdown
54 lines
2.2 KiB
Markdown
# 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`。
|