auto-deploy-demo/PORT_CONFIG.md

111 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 端口配置说明
## 端口分配
### 管理系统端口
- **端口**: 8888
- **用途**: Web管理界面
- **访问地址**: http://localhost:8888 (本地) 或 http://your-server-ip:8888 (服务器)
### 演示项目端口范围
- **端口范围**: 9000-9100
- **用途**: 部署的前端演示项目
- **分配方式**: 系统自动分配可用端口
- **最大并发**: 最多同时运行100个项目
## 端口选择说明
### 管理系统端口 (8888)
- 选择8888作为管理端口避开常见端口
- 不与常见服务冲突如80、443、3000、8080、3306等
- 便于记忆和配置
### 演示项目端口 (9000-9100)
- 选择9000-9100范围远离常用端口段
- 避免与系统服务端口冲突
- 提供100个可用端口满足并发需求
## 防火墙配置
### Windows防火墙
```powershell
# 开放管理端口
New-NetFirewallRule -DisplayName "Deploy System" -Direction Inbound -LocalPort 8888 -Protocol TCP -Action Allow
# 开放演示项目端口范围
New-NetFirewallRule -DisplayName "Deploy Projects" -Direction Inbound -LocalPort 9000-9100 -Protocol TCP -Action Allow
```
### Linux防火墙 (firewalld)
```bash
# 开放管理端口
firewall-cmd --permanent --add-port=8888/tcp
# 开放演示项目端口范围
firewall-cmd --permanent --add-port=9000-9100/tcp
# 重载防火墙
firewall-cmd --reload
```
### 腾讯云安全组
在腾讯云控制台配置以下安全组规则:
- **入站规则**:
- 协议: TCP
- 端口: 8888
- 策略: 允许
- 协议: TCP
- 端口: 9000-9100
- 策略: 允许
## 环境变量配置
创建 `.env` 文件配置端口:
```bash
PORT=8888
JWT_SECRET=your-secure-secret-key-change-this
HOST=your-server-ip
```
## 端口冲突排查
### 检查端口占用
**Windows:**
```powershell
Get-NetTCPConnection -State Listen | Where-Object {$_.LocalPort -eq 8888}
```
**Linux:**
```bash
lsof -i :8888
netstat -tuln | grep 8888
```
### 解决端口冲突
如果端口被占用,可以:
1. 停止占用端口的进程
2. 修改 `.env` 文件中的 `PORT`
3. 重启服务
## 端口使用示例
### 本地开发
```
管理界面: http://localhost:8888
演示项目: http://localhost:9000-9100
```
### 服务器部署
```
管理界面: http://your-server-ip:8888
演示项目: http://your-server-ip:9000-9100
```
### 域名访问 (Nginx反向代理)
```
管理界面: http://your-domain.com
演示项目: http://your-domain.com:9000-9100
```