feat: 配置宝塔部署端口映射

## 修改内容
### 生产环境端口映射
- API 服务:3000 → 10080
- 商家后台:8081 → 10082
- 平台后台:8082 → 10084
- 官网:8083 → 10086

### 测试环境端口映射
- API 服务:3001 → 10081
- 商家后台:9081 → 10083
- 平台后台:9082 → 10085
- 官网:9083 → 10087

## 新增文档
- PORT_MAPPING.md - 端口映射说明和部署步骤

## 设计说明
- 使用 10080-10087 端口段,避免常用端口冲突
- 通过宝塔反向代理访问,不需要开放这些端口到公网
- 端口规划清晰,便于管理和维护

## 配合文档
- 详细配置步骤见 BAOTA_PROXY_SETUP.md
- 域名配置见 DOMAIN_SETUP.md

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 16:37:33 +08:00
parent 951569f6cc
commit 6f970af5bc
3 changed files with 164 additions and 8 deletions
+156
View File
@@ -0,0 +1,156 @@
# 宝塔部署端口映射说明
## 📋 端口映射表
### 生产环境 (Production)
| 服务 | 容器名 | 容器端口 | 宿主机端口 | 宝塔反向代理域名 |
|------|--------|---------|-----------|----------------|
| API 服务 | rent-prod-server | 3000 | **10080** | api.pinzhuhui.com |
| 商家后台 | rent-prod-merchant | 80 | **10082** | merchant.pinzhuhui.com |
| 平台后台 | rent-prod-platform | 80 | **10084** | platform-admin.pinzhuhui.com |
| 官网 | rent-prod-website | 80 | **10086** | www.pinzhuhui.com |
### 测试环境 (Test)
| 服务 | 容器名 | 容器端口 | 宿主机端口 | 宝塔反向代理域名 |
|------|--------|---------|-----------|----------------|
| API 服务 | rent-test-server | 3000 | **10081** | api-test.pinzhuhui.com |
| 商家后台 | rent-test-merchant | 80 | **10083** | merchant-test.pinzhuhui.com |
| 平台后台 | rent-test-platform | 80 | **10085** | platform-admin-test.pinzhuhui.com |
| 官网 | rent-test-website | 80 | **10087** | test.pinzhuhui.com |
### 数据库和缓存
| 服务 | 生产环境端口 | 测试环境端口 | 说明 |
|------|------------|------------|------|
| MySQL | 3306 | 3307 | 数据库 |
| Redis | 6379 | 6380 | 缓存 |
---
## 🚀 部署步骤
### 1. 启动 Docker 容器
**测试环境**
```bash
cd /path/to/deploy/docker
docker-compose -f docker-compose.test.yml up -d
```
**生产环境**
```bash
cd /path/to/deploy/docker
docker-compose -f docker-compose.prod.yml up -d
```
### 2. 验证容器状态
```bash
# 查看所有容器
docker ps | grep rent
# 应该看到以下容器运行在对应端口
# rent-prod-server:10080
# rent-prod-merchant:10082
# rent-prod-platform:10084
# rent-prod-website:10086
# rent-test-server:10081
# rent-test-merchant:10083
# rent-test-platform:10085
# rent-test-website:10087
```
### 3. 测试端口访问
```bash
# 测试生产 API
curl http://127.0.0.1:10080
# 测试商家后台
curl http://127.0.0.1:10082
# 测试平台后台
curl http://127.0.0.1:10084
# 测试官网
curl http://127.0.0.1:10086
```
### 4. 在宝塔面板配置反向代理
详细步骤请参考:[BAOTA_PROXY_SETUP.md](./BAOTA_PROXY_SETUP.md)
---
## 🔒 端口安全
### 防火墙配置
只需要在服务器安全组/防火墙中开放:
-**80** (HTTP)
-**443** (HTTPS)
-**8888** (宝塔面板,建议修改默认端口)
**不需要**开放 10080-10087 端口,因为:
- 这些端口只在本地监听 `127.0.0.1`
- 通过宝塔反向代理访问
- 外部无法直接访问,更安全
### 宝塔安全设置
1. 登录宝塔面板
2. 点击 **"安全"**
3. 确认以下端口规则:
- ✅ 放行:80, 443
- ❌ 不需要放行:10080-10087(本地访问)
---
## 📝 配置文件
- 生产环境:`docker-compose.prod.yml`
- 测试环境:`docker-compose.test.yml`
- 宝塔配置指南:`BAOTA_PROXY_SETUP.md`
---
## 🔧 常见问题
### Q: 端口已被占用怎么办?
```bash
# 查看端口占用
netstat -tlnp | grep 10080
# 停止占用端口的容器
docker stop <container_id>
# 或修改 docker-compose.yml 中的端口映射
```
### Q: 如何查看容器日志?
```bash
# 查看所有容器日志
docker-compose -f docker-compose.prod.yml logs -f
# 查看特定容器日志
docker logs rent-prod-server -f
```
### Q: 如何重启服务?
```bash
# 重启所有服务
docker-compose -f docker-compose.prod.yml restart
# 重启单个服务
docker restart rent-prod-server
```
---
**最后更新**2026-06-09
**维护者**:开发团队
+4 -4
View File
@@ -48,7 +48,7 @@ services:
container_name: rent-prod-server
restart: always
ports:
- "3000:3000"
- "10080:3000" # 宝塔反向代理端口
environment:
NODE_ENV: production
PORT: 3000
@@ -79,7 +79,7 @@ services:
container_name: rent-prod-merchant
restart: always
ports:
- "8081:80"
- "10082:80" # 宝塔反向代理端口
depends_on:
- server
networks:
@@ -92,7 +92,7 @@ services:
container_name: rent-prod-platform
restart: always
ports:
- "8082:80"
- "10084:80" # 宝塔反向代理端口
depends_on:
- server
networks:
@@ -105,7 +105,7 @@ services:
container_name: rent-prod-website
restart: always
ports:
- "8083:80"
- "10086:80" # 宝塔反向代理端口
networks:
- rent-prod
+4 -4
View File
@@ -48,7 +48,7 @@ services:
container_name: rent-test-server
restart: always
ports:
- "3001:3000"
- "10081:3000" # 宝塔反向代理端口
environment:
NODE_ENV: test
PORT: 3000
@@ -76,7 +76,7 @@ services:
container_name: rent-test-merchant
restart: always
ports:
- "9081:80"
- "10083:80" # 宝塔反向代理端口
depends_on:
- server
networks:
@@ -89,7 +89,7 @@ services:
container_name: rent-test-platform
restart: always
ports:
- "9082:80"
- "10085:80" # 宝塔反向代理端口
depends_on:
- server
networks:
@@ -102,7 +102,7 @@ services:
container_name: rent-test-website
restart: always
ports:
- "9083:80"
- "10087:80" # 宝塔反向代理端口
networks:
- rent-test