diff --git a/doc/单机部署文档.md b/doc/单机部署文档.md index c13482e..94d3400 100644 --- a/doc/单机部署文档.md +++ b/doc/单机部署文档.md @@ -17,7 +17,7 @@ │ │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ 前端服务 │ │ -│ │ fund-admin (Nginx:80) fund-mobile (Nginx:81) │ │ +│ │ fund-admin (/fadmin/) fund-mobile (/fmobile/) │ │ │ └─────────────────────────┬───────────────────────────────┘ │ │ │ │ │ ┌─────────────────────────▼───────────────────────────────┐ │ @@ -431,7 +431,17 @@ fundplatform/ #### 4.2.4 前端打包 +前端项目采用 Nginx 子路径部署方式: +- **管理后台** (fund-admin): 部署路径 `/fadmin/` +- **移动端H5** (fund-mobile): 部署路径 `/fmobile/` +- **API网关前缀**: `/fund` + ```bash +# 使用部署脚本打包(推荐) +./scripts/deploy-frontend-nginx.sh admin # 管理后台 +./scripts/deploy-frontend-nginx.sh mobile # 移动端H5 + +# 或手动打包 # 管理后台打包 cd fund-admin npm install @@ -485,6 +495,54 @@ tar -xzf fund-receipt.tar.gz -C /opt/fundplatform/deploy/ tar -xzf fund-report.tar.gz -C /opt/fundplatform/deploy/ tar -xzf fund-file.tar.gz -C /opt/fundplatform/deploy/ +# 解压前端发布包 +mkdir -p /opt/fundplatform/web +unzip fund-admin-nginx.zip -d /opt/fundplatform/web/admin/ +unzip fund-mobile-nginx.zip -d /opt/fundplatform/web/mobile/ + +# 复制Nginx配置 +cp /opt/fundplatform/web/admin/nginx.conf /etc/nginx/conf.d/fadmin.conf +cp /opt/fundplatform/web/mobile/nginx.conf /etc/nginx/conf.d/fmobile.conf + +``` + +### 4.5 Nginx 配置 + +前端采用子路径部署,Nginx 配置示例: + +```nginx +# /etc/nginx/conf.d/fundplatform.conf +server { + listen 80; + server_name localhost; + + # 管理后台 (部署路径: /fadmin/) + location /fadmin/ { + alias /opt/fundplatform/web/admin/; + try_files $uri $uri/ /fadmin/index.html; + } + + # 移动端H5 (部署路径: /fmobile/) + location /fmobile/ { + alias /opt/fundplatform/web/mobile/; + try_files $uri $uri/ /fmobile/index.html; + } + + # API代理 (网关前缀: /fund) + location /fund/ { + proxy_pass http://127.0.0.1:8000/; + 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; + } +} +``` + +**访问地址**: +- 管理后台: `http://服务器IP/fadmin/` +- 移动端H5: `http://服务器IP/fmobile/` + ```bash # 上传一键管理脚本到deploy目录(在解压服务包后执行) # 一键管理脚本位于项目根目录scripts目录,需要单独上传 @@ -494,7 +552,7 @@ cp scripts/restart-all.sh /opt/fundplatform/deploy/ cp scripts/status-all.sh /opt/fundplatform/deploy/ ``` -### 4.5 配置文件修改 +### 4.6 配置文件修改 各服务配置文件需要根据实际环境修改以下配置: @@ -521,7 +579,7 @@ spring: namespace: fund-platform ``` -### 4.6 服务管理脚本 +### 4.7 服务管理脚本 每个服务的 `bin` 目录下包含以下脚本: diff --git a/doc/部署运维文档.md b/doc/部署运维文档.md index 584cf18..7c7a207 100644 --- a/doc/部署运维文档.md +++ b/doc/部署运维文档.md @@ -158,6 +158,7 @@ npm run dev # 4. 访问系统 # 管理后台:http://localhost:3000 +# 移动端H5:http://localhost:8080 # 网关地址:http://localhost:8000 # Nacos 控制台:http://localhost:8048/nacos # Grafana 监控:http://localhost:3000 (Docker环境) 或 http://localhost:3001 (本地开发) @@ -179,8 +180,8 @@ npm run dev │ │ │ ┌──────────────┐ │ │ │ 前端服务 │ │ -│ │ fund-admin │ ← 管理后台 (http://localhost:80) │ -│ │ fund-mobile │ ← 移动端H5 (http://localhost:81) │ +│ │ fund-admin │ ← 管理后台 (http://localhost/fadmin/) │ +│ │ fund-mobile │ ← 移动端H5 (http://localhost/fmobile/) │ │ └──────┬───────┘ │ │ │ │ │ ┌──────┴───────┐ │ @@ -224,8 +225,8 @@ npm run dev | 服务 | 端口 | 说明 | |------|------|------| -| fund-admin | 80 | 管理后台前端 | -| fund-mobile | 81 | 移动端H5 | +| fund-admin | 80 | 管理后台前端 (访问路径: /fadmin/) | +| fund-mobile | 80 | 移动端H5 (访问路径: /fmobile/) | | gateway | 8000 | API网关 | | fund-sys | 8100 | 系统管理服务 | | fund-sys-vip001 | 8101 | 系统服务VIP专属实例 | @@ -480,14 +481,20 @@ server { listen 80; server_name test.fundplatform.com; - # 前端静态资源 - location / { - root /opt/fundplatform/admin; - try_files $uri $uri/ /index.html; + # 管理后台前端 (部署路径: /fadmin/) + location /fadmin/ { + alias /opt/fundplatform/admin/; + try_files $uri $uri/ /fadmin/index.html; } - # API 代理 - location /api/ { + # 移动端H5 (部署路径: /fmobile/) + location /fmobile/ { + alias /opt/fundplatform/mobile/; + try_files $uri $uri/ /fmobile/index.html; + } + + # API 代理 (网关前缀: /fund) + location /fund/ { proxy_pass http://gateway/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;