feat(config): 更新配置以支持HTTPS域名访问
- 将所有环境的前端URL从localhost和IP地址更新为https://shopd.mtkj2025.com - 配置PayPal webhook使用HTTPS域名以满足PayPal安全要求 - 统一后端服务端口从18082调整为8082 - 更新Java代码中的默认URL配置和启动日志信息 - 创建域名配置、Nginx SSL配置和公网访问检查清单文档 - 为商品链接生成和API访问配置HTTPS协议支持
This commit is contained in:
@@ -5,8 +5,9 @@
|
|||||||
### 后端部署
|
### 后端部署
|
||||||
|
|
||||||
1. **配置文件已更新**
|
1. **配置文件已更新**
|
||||||
- ✅ `app.frontend.url` 已设置为 `http://175.178.252.59:3000`
|
- ✅ `app.frontend.url` 已设置为 `http://175.178.252.59`(公网地址,通过Nginx访问)
|
||||||
- ✅ `paypal.webhook-url` 已设置为 `http://175.178.252.59:18082/api/paypal/webhook`
|
- ✅ `paypal.webhook-url` 已设置为 `https://175.178.252.59/api/paypal/webhook`(HTTPS,PayPal要求)
|
||||||
|
- ✅ 后端端口已设置为 `8082`
|
||||||
- ✅ 前端 `.env.production` 已创建,API地址为 `/api`(相对路径)
|
- ✅ 前端 `.env.production` 已创建,API地址为 `/api`(相对路径)
|
||||||
|
|
||||||
2. **打包应用**
|
2. **打包应用**
|
||||||
@@ -61,12 +62,14 @@
|
|||||||
|
|
||||||
部署前请检查以下配置:
|
部署前请检查以下配置:
|
||||||
|
|
||||||
- [x] 后端 `app.frontend.url` 已设置为 `http://175.178.252.59:3000`
|
- [x] 后端 `app.frontend.url` 已设置为 `http://175.178.252.59`(公网地址)
|
||||||
- [x] 后端 `paypal.webhook-url` 已设置为 `http://175.178.252.59:18082/api/paypal/webhook`
|
- [x] 后端 `paypal.webhook-url` 已设置为 `https://175.178.252.59/api/paypal/webhook`(HTTPS)
|
||||||
|
- [x] 后端端口已设置为 `8082`
|
||||||
- [x] 前端API地址已配置为 `/api`(相对路径,通过Nginx代理)
|
- [x] 前端API地址已配置为 `/api`(相对路径,通过Nginx代理)
|
||||||
- [ ] 数据库连接信息正确
|
- [ ] 数据库连接信息正确
|
||||||
- [ ] 服务器防火墙已开放必要端口(18082、3000等)
|
- [ ] 服务器防火墙已开放必要端口(8082等)
|
||||||
- [ ] PayPal控制台Webhook URL已更新为 `http://175.178.252.59:18082/api/paypal/webhook`
|
- [ ] **Nginx已配置SSL证书(PayPal Webhook必需)**
|
||||||
- [ ] **Nginx配置中的proxy_pass端口已更新为18082**
|
- [ ] PayPal控制台Webhook URL已更新为 `https://175.178.252.59/api/paypal/webhook`
|
||||||
|
- [ ] **Nginx配置中的proxy_pass端口已更新为8082**
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
134
DOMAIN_CONFIG_SUMMARY.md
Normal file
134
DOMAIN_CONFIG_SUMMARY.md
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
# 域名配置总结
|
||||||
|
|
||||||
|
## ✅ 已完成的配置修改
|
||||||
|
|
||||||
|
### 域名信息
|
||||||
|
- **域名**: `shopd.mtkj2025.com`
|
||||||
|
- **SSL证书**: 已配置(Let's Encrypt)
|
||||||
|
- **协议**: HTTPS(443端口)
|
||||||
|
|
||||||
|
### 1. 后端配置文件
|
||||||
|
|
||||||
|
#### application-dev.yml
|
||||||
|
- ✅ `app.frontend.url: https://shopd.mtkj2025.com`
|
||||||
|
- ✅ `paypal.webhook-url: https://shopd.mtkj2025.com/api/paypal/webhook`
|
||||||
|
|
||||||
|
#### application-prod.yml
|
||||||
|
- ✅ `app.frontend.url: ${app.frontend.url:https://shopd.mtkj2025.com}`
|
||||||
|
- ✅ `paypal.webhook-url: ${paypal.webhook-url:https://shopd.mtkj2025.com/api/paypal/webhook}`
|
||||||
|
|
||||||
|
#### mt-startup/application-dev.yml
|
||||||
|
- ✅ `app.frontend.url: https://shopd.mtkj2025.com`
|
||||||
|
|
||||||
|
#### mt-startup/application.yml
|
||||||
|
- ✅ `app.frontend.url: https://shopd.mtkj2025.com`
|
||||||
|
|
||||||
|
### 2. Java代码
|
||||||
|
|
||||||
|
#### ProductServiceImpl.java
|
||||||
|
- ✅ 默认值: `https://shopd.mtkj2025.com`
|
||||||
|
- ✅ 注释示例已更新
|
||||||
|
|
||||||
|
#### ProductLinkServiceImpl.java
|
||||||
|
- ✅ 默认值: `https://shopd.mtkj2025.com`
|
||||||
|
|
||||||
|
#### MtPayApplication.java
|
||||||
|
- ✅ 启动日志使用域名和HTTPS协议
|
||||||
|
- ✅ 前端地址提示: `https://shopd.mtkj2025.com`
|
||||||
|
|
||||||
|
#### MtkjpayApplication.java
|
||||||
|
- ✅ 启动日志使用域名和HTTPS协议
|
||||||
|
- ✅ 前端地址提示: `https://shopd.mtkj2025.com`
|
||||||
|
|
||||||
|
### 3. 前端配置
|
||||||
|
|
||||||
|
#### .env.production
|
||||||
|
- ✅ `VITE_API_BASE_URL=/api`(相对路径,自动使用当前域名)
|
||||||
|
|
||||||
|
#### config/index.js
|
||||||
|
- ✅ 使用相对路径,自动适配HTTPS域名
|
||||||
|
|
||||||
|
## 📋 配置说明
|
||||||
|
|
||||||
|
### 前端URL配置
|
||||||
|
- **配置值**: `https://shopd.mtkj2025.com`
|
||||||
|
- **用途**: 生成商品详情页链接
|
||||||
|
- **格式**: `https://shopd.mtkj2025.com/product/{linkCode}`
|
||||||
|
|
||||||
|
### PayPal Webhook配置
|
||||||
|
- **配置值**: `https://shopd.mtkj2025.com/api/paypal/webhook`
|
||||||
|
- **要求**: PayPal只接受HTTPS(端口443)
|
||||||
|
- **说明**: 通过Nginx SSL转发到后端8082端口
|
||||||
|
|
||||||
|
### 前端API请求
|
||||||
|
- **配置**: 相对路径 `/api`
|
||||||
|
- **说明**: 自动使用当前域名和协议(HTTPS)
|
||||||
|
- **实际请求**: `https://shopd.mtkj2025.com/api/xxx`
|
||||||
|
|
||||||
|
## 🔧 服务器配置要求
|
||||||
|
|
||||||
|
### Nginx配置
|
||||||
|
需要确保Nginx配置支持:
|
||||||
|
1. **HTTPS监听**(443端口)
|
||||||
|
2. **SSL证书**(已配置)
|
||||||
|
3. **强制HTTPS**(建议开启)
|
||||||
|
4. **API反向代理**(转发到后端8082)
|
||||||
|
|
||||||
|
### 防火墙
|
||||||
|
- ✅ 443端口已开放(HTTPS)
|
||||||
|
- ✅ 80端口已开放(HTTP,可重定向到HTTPS)
|
||||||
|
- ✅ 8082端口已开放(后端服务,仅内网访问)
|
||||||
|
|
||||||
|
## 📝 下一步操作
|
||||||
|
|
||||||
|
### 1. 重新打包后端
|
||||||
|
```bash
|
||||||
|
cd E:\MTKJPAY
|
||||||
|
mvn clean package -DskipTests
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 上传并部署
|
||||||
|
- 上传新的jar包到服务器
|
||||||
|
- 重启后端服务
|
||||||
|
|
||||||
|
### 3. 更新PayPal控制台
|
||||||
|
- Webhook URL: `https://shopd.mtkj2025.com/api/paypal/webhook`
|
||||||
|
- 测试Webhook连接
|
||||||
|
|
||||||
|
### 4. 验证配置
|
||||||
|
- 访问前端: `https://shopd.mtkj2025.com`
|
||||||
|
- 测试API: `https://shopd.mtkj2025.com/api/health`
|
||||||
|
- 创建商品,检查生成的链接是否为: `https://shopd.mtkj2025.com/product/xxxxx`
|
||||||
|
|
||||||
|
## ⚠️ 重要提示
|
||||||
|
|
||||||
|
1. **强制HTTPS**
|
||||||
|
- 在宝塔面板中开启"强制HTTPS"开关
|
||||||
|
- 确保所有HTTP请求自动重定向到HTTPS
|
||||||
|
|
||||||
|
2. **商品链接生成**
|
||||||
|
- 所有生成的商品链接将使用: `https://shopd.mtkj2025.com/product/{linkCode}`
|
||||||
|
- 确保链接可以通过HTTPS正常访问
|
||||||
|
|
||||||
|
3. **PayPal Webhook**
|
||||||
|
- 必须使用HTTPS域名
|
||||||
|
- 确保Nginx正确转发到后端
|
||||||
|
- 测试Webhook连接是否正常
|
||||||
|
|
||||||
|
4. **前端访问**
|
||||||
|
- 前端通过HTTPS访问: `https://shopd.mtkj2025.com`
|
||||||
|
- API请求自动使用HTTPS: `https://shopd.mtkj2025.com/api/xxx`
|
||||||
|
|
||||||
|
## ✅ 配置检查清单
|
||||||
|
|
||||||
|
- [x] 所有配置文件中的URL已更新为域名
|
||||||
|
- [x] 所有URL使用HTTPS协议
|
||||||
|
- [x] Java代码默认值已更新
|
||||||
|
- [x] 启动日志已更新
|
||||||
|
- [x] 前端使用相对路径(自动适配域名)
|
||||||
|
- [ ] 重新打包后端
|
||||||
|
- [ ] 上传并部署新版本
|
||||||
|
- [ ] 在宝塔面板开启"强制HTTPS"
|
||||||
|
- [ ] 更新PayPal控制台Webhook URL
|
||||||
|
- [ ] 验证所有功能正常
|
||||||
|
|
||||||
190
NGINX_SSL_CONFIG.md
Normal file
190
NGINX_SSL_CONFIG.md
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
# Nginx SSL配置指南(PayPal Webhook必需)
|
||||||
|
|
||||||
|
## 问题说明
|
||||||
|
|
||||||
|
PayPal Webhook **只接受HTTPS(端口443)**的URL,不接受HTTP或其他端口。
|
||||||
|
|
||||||
|
当前配置:
|
||||||
|
- ❌ `http://175.178.252.59:8082/api/paypal/webhook` - PayPal不接受
|
||||||
|
- ✅ `https://175.178.252.59/api/paypal/webhook` - PayPal接受
|
||||||
|
|
||||||
|
## 解决方案
|
||||||
|
|
||||||
|
需要通过Nginx配置SSL证书,将HTTPS请求转发到后端的HTTP服务。
|
||||||
|
|
||||||
|
## 配置步骤
|
||||||
|
|
||||||
|
### 1. 在宝塔面板中配置SSL证书
|
||||||
|
|
||||||
|
1. **进入网站设置**
|
||||||
|
- 宝塔面板 → 网站 → 选择你的网站(175.178.252.59)
|
||||||
|
- 点击"设置" → "SSL"
|
||||||
|
|
||||||
|
2. **申请或配置SSL证书**
|
||||||
|
|
||||||
|
**选项A:使用Let's Encrypt免费证书(推荐)**
|
||||||
|
- 点击"Let's Encrypt"
|
||||||
|
- 输入域名(如果有)或使用IP地址
|
||||||
|
- 点击"申请"
|
||||||
|
- 等待证书申请完成
|
||||||
|
|
||||||
|
**选项B:使用自签名证书(仅测试用)**
|
||||||
|
- 点击"自签证书"
|
||||||
|
- 生成自签名证书
|
||||||
|
- ⚠️ 注意:自签名证书PayPal可能不接受,建议使用Let's Encrypt
|
||||||
|
|
||||||
|
3. **启用HTTPS**
|
||||||
|
- 证书申请成功后,点击"强制HTTPS"
|
||||||
|
- 保存配置
|
||||||
|
|
||||||
|
### 2. 配置Nginx反向代理(SSL)
|
||||||
|
|
||||||
|
在宝塔面板中:
|
||||||
|
1. 网站 → 设置 → 配置文件
|
||||||
|
2. 找到 `location /api/` 配置块
|
||||||
|
3. 确保配置如下:
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
# HTTP请求重定向到HTTPS(可选,如果启用了强制HTTPS)
|
||||||
|
# server {
|
||||||
|
# listen 80;
|
||||||
|
# server_name 175.178.252.59;
|
||||||
|
# return 301 https://$server_name$request_uri;
|
||||||
|
# }
|
||||||
|
|
||||||
|
# HTTPS服务器配置
|
||||||
|
server {
|
||||||
|
listen 443 ssl http2;
|
||||||
|
listen [::]:443 ssl http2;
|
||||||
|
server_name 175.178.252.59;
|
||||||
|
|
||||||
|
# SSL证书配置(宝塔会自动配置)
|
||||||
|
ssl_certificate /www/server/panel/vhost/cert/175.178.252.59/fullchain.pem;
|
||||||
|
ssl_certificate_key /www/server/panel/vhost/cert/175.178.252.59/privkey.pem;
|
||||||
|
|
||||||
|
# SSL配置(宝塔会自动配置)
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
|
||||||
|
root /www/wwwroot/175.178.252.59;
|
||||||
|
index index.html index.htm;
|
||||||
|
|
||||||
|
# 前端路由配置
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# API反向代理(关键配置)
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://127.0.0.1:8082; # 转发到后端HTTP服务
|
||||||
|
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; # 传递原始协议(HTTPS)
|
||||||
|
|
||||||
|
# WebSocket支持(如果需要)
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
|
||||||
|
# 超时配置
|
||||||
|
proxy_connect_timeout 60s;
|
||||||
|
proxy_send_timeout 60s;
|
||||||
|
proxy_read_timeout 60s;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 静态资源缓存
|
||||||
|
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
|
||||||
|
expires 30d;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ .*\.(js|css)?$ {
|
||||||
|
expires 12h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 修改后端配置
|
||||||
|
|
||||||
|
后端配置文件已更新:
|
||||||
|
- `application-dev.yml`: `paypal.webhook-url: https://175.178.252.59/api/paypal/webhook`
|
||||||
|
|
||||||
|
### 4. 更新PayPal控制台
|
||||||
|
|
||||||
|
在PayPal控制台中配置Webhook URL:
|
||||||
|
- **Webhook URL**: `https://175.178.252.59/api/paypal/webhook`
|
||||||
|
- ✅ 使用HTTPS(不是HTTP)
|
||||||
|
- ✅ 不指定端口(默认443)
|
||||||
|
- ✅ 通过Nginx转发到后端
|
||||||
|
|
||||||
|
### 5. 验证配置
|
||||||
|
|
||||||
|
1. **测试HTTPS访问**
|
||||||
|
```bash
|
||||||
|
curl https://175.178.252.59/api/health
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **测试Webhook端点**
|
||||||
|
```bash
|
||||||
|
curl -X POST https://175.178.252.59/api/paypal/webhook \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"test": "data"}'
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **检查PayPal Webhook配置**
|
||||||
|
- 在PayPal控制台测试Webhook
|
||||||
|
- 应该不再显示端口错误
|
||||||
|
|
||||||
|
## 重要提示
|
||||||
|
|
||||||
|
1. **SSL证书是必需的**
|
||||||
|
- PayPal只接受HTTPS
|
||||||
|
- 建议使用Let's Encrypt免费证书
|
||||||
|
- 自签名证书PayPal可能不接受
|
||||||
|
|
||||||
|
2. **Nginx配置要点**
|
||||||
|
- 监听443端口(HTTPS)
|
||||||
|
- 将 `/api/` 请求转发到 `http://127.0.0.1:8082`
|
||||||
|
- 设置 `X-Forwarded-Proto` 头,让后端知道原始请求是HTTPS
|
||||||
|
|
||||||
|
3. **后端不需要修改**
|
||||||
|
- 后端仍然监听8082端口(HTTP)
|
||||||
|
- Nginx负责SSL终止和转发
|
||||||
|
|
||||||
|
4. **防火墙配置**
|
||||||
|
- 确保443端口已开放
|
||||||
|
- 80端口可以重定向到443
|
||||||
|
|
||||||
|
## 常见问题
|
||||||
|
|
||||||
|
### Q1: 没有域名,只有IP地址,能申请SSL证书吗?
|
||||||
|
|
||||||
|
**A:** Let's Encrypt需要域名,不能为IP地址签发证书。解决方案:
|
||||||
|
- 使用自签名证书(PayPal可能不接受)
|
||||||
|
- 使用内网穿透服务(如ngrok、cpolar)提供HTTPS
|
||||||
|
- 申请一个域名并解析到服务器IP
|
||||||
|
|
||||||
|
### Q2: 使用自签名证书PayPal会接受吗?
|
||||||
|
|
||||||
|
**A:** 通常不会。PayPal会验证SSL证书的有效性,自签名证书会被拒绝。建议:
|
||||||
|
- 使用Let's Encrypt免费证书(需要域名)
|
||||||
|
- 或使用内网穿透服务
|
||||||
|
|
||||||
|
### Q3: 如何测试Webhook是否正常工作?
|
||||||
|
|
||||||
|
**A:**
|
||||||
|
1. 在PayPal控制台发送测试Webhook
|
||||||
|
2. 查看后端日志,确认收到请求
|
||||||
|
3. 检查Nginx访问日志和错误日志
|
||||||
|
|
||||||
|
## 配置检查清单
|
||||||
|
|
||||||
|
- [ ] SSL证书已申请并配置
|
||||||
|
- [ ] Nginx监听443端口
|
||||||
|
- [ ] `/api/` 路径正确转发到 `http://127.0.0.1:8082`
|
||||||
|
- [ ] 后端配置中的webhook URL已改为HTTPS
|
||||||
|
- [ ] PayPal控制台Webhook URL已更新为 `https://175.178.252.59/api/paypal/webhook`
|
||||||
|
- [ ] 443端口已开放防火墙
|
||||||
|
- [ ] 测试HTTPS访问正常
|
||||||
|
|
||||||
120
PUBLIC_ACCESS_CHECKLIST.md
Normal file
120
PUBLIC_ACCESS_CHECKLIST.md
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
# 公网访问配置检查清单
|
||||||
|
|
||||||
|
## ✅ 已完成的配置修改
|
||||||
|
|
||||||
|
### 1. 后端配置
|
||||||
|
|
||||||
|
#### 端口配置
|
||||||
|
- ✅ `application-dev.yml`: `server.port: 8082`
|
||||||
|
- ✅ `application-prod.yml`: `server.port: ${server.port:8082}`
|
||||||
|
- ✅ `ProductServiceImpl.java`: 默认端口改为 `8082`
|
||||||
|
|
||||||
|
#### 前端URL配置(用于生成商品链接)
|
||||||
|
- ✅ `application-dev.yml`: `app.frontend.url: http://175.178.252.59`
|
||||||
|
- ✅ `application-prod.yml`: `app.frontend.url: ${app.frontend.url:http://175.178.252.59}`
|
||||||
|
- ✅ `mt-startup/application-dev.yml`: `app.frontend.url: http://175.178.252.59`
|
||||||
|
- ✅ `mt-startup/application.yml`: `app.frontend.url: http://175.178.252.59`
|
||||||
|
- ✅ `ProductServiceImpl.java`: 默认值改为 `http://175.178.252.59`
|
||||||
|
- ✅ `ProductLinkServiceImpl.java`: 默认值改为 `http://175.178.252.59`
|
||||||
|
|
||||||
|
#### PayPal Webhook配置
|
||||||
|
- ✅ `application-dev.yml`: `paypal.webhook-url: https://175.178.252.59/api/paypal/webhook`(HTTPS,PayPal要求)
|
||||||
|
|
||||||
|
#### 启动类日志
|
||||||
|
- ✅ `MtPayApplication.java`: 启动日志使用公网地址
|
||||||
|
- ✅ `MtkjpayApplication.java`: 启动日志使用公网地址
|
||||||
|
|
||||||
|
### 2. 前端配置
|
||||||
|
|
||||||
|
#### API地址
|
||||||
|
- ✅ `.env.production`: `VITE_API_BASE_URL=/api`(相对路径,通过Nginx代理)
|
||||||
|
- ✅ `vite.config.js`: 开发环境代理(保留127.0.0.1,仅用于本地开发)
|
||||||
|
|
||||||
|
### 3. 代码注释
|
||||||
|
- ✅ `ProductServiceImpl.java`: 注释中的示例URL已更新为公网地址
|
||||||
|
|
||||||
|
## 📋 部署前检查清单
|
||||||
|
|
||||||
|
### 后端检查
|
||||||
|
- [x] 端口配置为 `8082`
|
||||||
|
- [x] 前端URL配置为 `http://175.178.252.59`(无端口,通过Nginx访问)
|
||||||
|
- [x] PayPal Webhook URL配置为 `https://175.178.252.59/api/paypal/webhook`(HTTPS)
|
||||||
|
- [ ] 重新打包后端:`mvn clean package -DskipTests`
|
||||||
|
- [ ] 上传新的jar包到服务器
|
||||||
|
- [ ] 启动后端服务并确认监听在 `8082` 端口
|
||||||
|
|
||||||
|
### 前端检查
|
||||||
|
- [x] `.env.production` 使用相对路径 `/api`
|
||||||
|
- [ ] 重新构建前端:`npm run build`
|
||||||
|
- [ ] 上传新的dist目录到服务器
|
||||||
|
|
||||||
|
### Nginx配置检查
|
||||||
|
- [ ] `proxy_pass` 端口为 `8082`:
|
||||||
|
```nginx
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://127.0.0.1:8082;
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- [ ] Nginx配置已保存并重载
|
||||||
|
|
||||||
|
### PayPal配置检查
|
||||||
|
- [ ] **Nginx已配置SSL证书(PayPal Webhook必需,只接受HTTPS)**
|
||||||
|
- [ ] PayPal控制台Webhook URL已更新为:`https://175.178.252.59/api/paypal/webhook`
|
||||||
|
|
||||||
|
### 防火墙检查
|
||||||
|
- [ ] 端口 `8082` 已开放(如果需要外部直接访问)
|
||||||
|
- [ ] 端口 `80` 已开放(Nginx前端访问)
|
||||||
|
|
||||||
|
## 🔍 验证步骤
|
||||||
|
|
||||||
|
### 1. 验证后端服务
|
||||||
|
```bash
|
||||||
|
# 在服务器上执行
|
||||||
|
curl http://127.0.0.1:8082/api/health
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. 验证Nginx代理
|
||||||
|
```bash
|
||||||
|
# 在服务器上执行
|
||||||
|
curl http://127.0.0.1/api/health
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 验证商品链接生成
|
||||||
|
- 创建商品后,检查生成的链接是否为:`http://175.178.252.59/product/xxxxx`
|
||||||
|
- 不应包含 `localhost` 或端口号
|
||||||
|
|
||||||
|
### 4. 验证前端访问
|
||||||
|
- 浏览器访问:`http://175.178.252.59`
|
||||||
|
- 检查浏览器控制台(F12)中的API请求
|
||||||
|
- 请求URL应为:`http://175.178.252.59/api/xxx`(通过Nginx代理)
|
||||||
|
|
||||||
|
## ⚠️ 重要提示
|
||||||
|
|
||||||
|
1. **前端URL不需要端口号**
|
||||||
|
- 配置为:`http://175.178.252.59`(不是 `http://175.178.252.59:3000`)
|
||||||
|
- 因为前端通过Nginx访问,默认使用80端口
|
||||||
|
|
||||||
|
2. **后端API配置**
|
||||||
|
- PayPal Webhook通过Nginx HTTPS访问:`https://175.178.252.59/api/paypal/webhook`(Nginx转发到后端8082)
|
||||||
|
- 前端通过Nginx代理访问:`http://175.178.252.59/api/xxx`(Nginx转发到8082)
|
||||||
|
- ⚠️ **重要:** PayPal只接受HTTPS(端口443),必须配置SSL证书
|
||||||
|
|
||||||
|
3. **商品链接生成**
|
||||||
|
- 使用 `app.frontend.url` 配置生成
|
||||||
|
- 格式:`{frontendUrl}/product/{linkCode}`
|
||||||
|
- 示例:`http://175.178.252.59/product/2563c74bd94c4a4b95abccf697a6c756`
|
||||||
|
|
||||||
|
## 📝 修改总结
|
||||||
|
|
||||||
|
所有 `localhost` 和硬编码地址已替换为公网地址 `175.178.252.59`:
|
||||||
|
- ✅ 配置文件中的URL
|
||||||
|
- ✅ Java代码中的默认值
|
||||||
|
- ✅ 启动日志中的提示信息
|
||||||
|
- ✅ 代码注释中的示例
|
||||||
|
|
||||||
|
所有端口已统一为 `8082`:
|
||||||
|
- ✅ 后端服务端口
|
||||||
|
- ✅ PayPal Webhook URL
|
||||||
|
- ✅ 代码中的默认值
|
||||||
|
|
||||||
@@ -32,8 +32,10 @@ public class MtPayApplication {
|
|||||||
String contextPath = env.getProperty("server.servlet.context-path", "");
|
String contextPath = env.getProperty("server.servlet.context-path", "");
|
||||||
String activeProfiles = String.join(",", env.getActiveProfiles());
|
String activeProfiles = String.join(",", env.getActiveProfiles());
|
||||||
|
|
||||||
// 构建完整的访问地址
|
// 构建完整的访问地址(使用域名)
|
||||||
String baseUrl = "http://localhost:" + serverPort + contextPath;
|
String serverHost = env.getProperty("app.server.host", "shopd.mtkj2025.com");
|
||||||
|
String protocol = env.getProperty("app.server.protocol", "https");
|
||||||
|
String baseUrl = protocol + "://" + serverHost + ":" + serverPort + contextPath;
|
||||||
String apiUrl = baseUrl + "/api";
|
String apiUrl = baseUrl + "/api";
|
||||||
String druidUrl = baseUrl + "/druid";
|
String druidUrl = baseUrl + "/druid";
|
||||||
|
|
||||||
@@ -71,7 +73,7 @@ public class MtPayApplication {
|
|||||||
log.info("""
|
log.info("""
|
||||||
|
|
||||||
📌 提示:
|
📌 提示:
|
||||||
- 前端代理地址: http://localhost:3000
|
- 前端地址: https://shopd.mtkj2025.com
|
||||||
- 后端API地址: {}
|
- 后端API地址: {}
|
||||||
- 图片上传接口: {}/product/upload/image
|
- 图片上传接口: {}/product/upload/image
|
||||||
- 商品管理接口: {}/product
|
- 商品管理接口: {}/product
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class ProductLinkServiceImpl implements ProductLinkService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MtProductLinkMapper productLinkMapper;
|
private MtProductLinkMapper productLinkMapper;
|
||||||
|
|
||||||
@Value("${app.frontend.url:http://localhost:3000}")
|
@Value("${app.frontend.url:https://shopd.mtkj2025.com}")
|
||||||
private String frontendUrl;
|
private String frontendUrl;
|
||||||
|
|
||||||
private static final int DEFAULT_EXPIRE_DAYS = 90;
|
private static final int DEFAULT_EXPIRE_DAYS = 90;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class ProductServiceImpl implements ProductService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private BaiduTranslatorUtils baiduTranslatorUtils;
|
private BaiduTranslatorUtils baiduTranslatorUtils;
|
||||||
|
|
||||||
@Value("${server.port:18082}")
|
@Value("${server.port:8082}")
|
||||||
private String serverPort;
|
private String serverPort;
|
||||||
|
|
||||||
@Value("${server.servlet.context-path:}")
|
@Value("${server.servlet.context-path:}")
|
||||||
@@ -72,7 +72,7 @@ public class ProductServiceImpl implements ProductService {
|
|||||||
/**
|
/**
|
||||||
* 前端访问地址(用于生成商品详情页URL)
|
* 前端访问地址(用于生成商品详情页URL)
|
||||||
*/
|
*/
|
||||||
@Value("${app.frontend.url:http://localhost:3000}")
|
@Value("${app.frontend.url:https://shopd.mtkj2025.com}")
|
||||||
private String frontendUrl;
|
private String frontendUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -858,7 +858,7 @@ public class ProductServiceImpl implements ProductService {
|
|||||||
/**
|
/**
|
||||||
* 从完整URL中提取链接码
|
* 从完整URL中提取链接码
|
||||||
* 支持两种输入:
|
* 支持两种输入:
|
||||||
* 1. 完整URL:http://localhost:3000/product/2563c74bd94c4a4b95abccf697a6c756
|
* 1. 完整URL:https://shopd.mtkj2025.com/product/2563c74bd94c4a4b95abccf697a6c756
|
||||||
* 2. 链接码:2563c74bd94c4a4b95abccf697a6c756
|
* 2. 链接码:2563c74bd94c4a4b95abccf697a6c756
|
||||||
*
|
*
|
||||||
* @param input 用户输入的URL或链接码
|
* @param input 用户输入的URL或链接码
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ spring:
|
|||||||
|
|
||||||
# 服务器配置(所有环境通用)
|
# 服务器配置(所有环境通用)
|
||||||
server:
|
server:
|
||||||
port: 18082
|
port: 8082
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /
|
context-path: /
|
||||||
# 文件上传配置
|
# 文件上传配置
|
||||||
@@ -78,8 +78,9 @@ server:
|
|||||||
# 应用配置(所有环境通用)
|
# 应用配置(所有环境通用)
|
||||||
app:
|
app:
|
||||||
# 前端访问地址(用于生成商品详情页URL等)
|
# 前端访问地址(用于生成商品详情页URL等)
|
||||||
|
# 注意:已配置SSL证书,使用HTTPS和域名
|
||||||
frontend:
|
frontend:
|
||||||
url: http://175.178.252.59:3000
|
url: https://shopd.mtkj2025.com
|
||||||
|
|
||||||
# 阿里云OSS相关配置(所有环境通用)
|
# 阿里云OSS相关配置(所有环境通用)
|
||||||
aliyun:
|
aliyun:
|
||||||
@@ -111,9 +112,10 @@ paypal:
|
|||||||
mode: sandbox
|
mode: sandbox
|
||||||
# 是否启用PayPal支付
|
# 是否启用PayPal支付
|
||||||
enabled: true
|
enabled: true
|
||||||
# Webhook URL(服务器公网地址)
|
# Webhook URL(服务器公网地址,必须使用HTTPS,端口443)
|
||||||
# 注意:需要在PayPal控制台配置此URL
|
# 注意:PayPal只接受HTTPS(端口443)的Webhook URL
|
||||||
webhook-url: http://175.178.252.59:18082/api/paypal/webhook
|
# 已配置SSL证书,使用域名访问
|
||||||
|
webhook-url: https://shopd.mtkj2025.com/api/paypal/webhook
|
||||||
# Webhook ID(从PayPal控制台获取,用于验证Webhook签名)
|
# Webhook ID(从PayPal控制台获取,用于验证Webhook签名)
|
||||||
webhook-id: 0SX6117212808615P
|
webhook-id: 0SX6117212808615P
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ spring:
|
|||||||
|
|
||||||
# 服务器配置
|
# 服务器配置
|
||||||
server:
|
server:
|
||||||
port: ${server.port:18082}
|
port: ${server.port:8082}
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /
|
context-path: /
|
||||||
multipart:
|
multipart:
|
||||||
@@ -72,9 +72,9 @@ server:
|
|||||||
|
|
||||||
# 应用配置
|
# 应用配置
|
||||||
app:
|
app:
|
||||||
# 前端访问地址
|
# 前端访问地址(已配置SSL证书,使用HTTPS和域名)
|
||||||
frontend:
|
frontend:
|
||||||
url: ${app.frontend.url:http://175.178.252.59:3000}
|
url: ${app.frontend.url:https://shopd.mtkj2025.com}
|
||||||
|
|
||||||
# PingPong支付配置(生产环境)
|
# PingPong支付配置(生产环境)
|
||||||
pingpong:
|
pingpong:
|
||||||
@@ -99,8 +99,8 @@ paypal:
|
|||||||
mode: sandbox
|
mode: sandbox
|
||||||
# 是否启用PayPal支付
|
# 是否启用PayPal支付
|
||||||
enabled: true
|
enabled: true
|
||||||
# Webhook URL(部署时请修改为服务器的公网地址)
|
# Webhook URL(已配置SSL证书,使用HTTPS和域名)
|
||||||
webhook-url: ${paypal.webhook-url:https://your-domain.com/api/paypal/webhook}
|
webhook-url: ${paypal.webhook-url:https://shopd.mtkj2025.com/api/paypal/webhook}
|
||||||
# Webhook ID(从PayPal控制台获取)
|
# Webhook ID(从PayPal控制台获取)
|
||||||
webhook-id: ${paypal.webhook-id:}
|
webhook-id: ${paypal.webhook-id:}
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,10 @@ public class MtkjpayApplication {
|
|||||||
String contextPath = env.getProperty("server.servlet.context-path", "");
|
String contextPath = env.getProperty("server.servlet.context-path", "");
|
||||||
String activeProfiles = String.join(",", env.getActiveProfiles());
|
String activeProfiles = String.join(",", env.getActiveProfiles());
|
||||||
|
|
||||||
// 构建完整的访问地址
|
// 构建完整的访问地址(使用域名)
|
||||||
String baseUrl = "http://localhost:" + serverPort + contextPath;
|
String serverHost = env.getProperty("app.server.host", "shopd.mtkj2025.com");
|
||||||
|
String protocol = env.getProperty("app.server.protocol", "https");
|
||||||
|
String baseUrl = protocol + "://" + serverHost + ":" + serverPort + contextPath;
|
||||||
String apiUrl = baseUrl + "/api";
|
String apiUrl = baseUrl + "/api";
|
||||||
String druidUrl = baseUrl + "/druid";
|
String druidUrl = baseUrl + "/druid";
|
||||||
|
|
||||||
@@ -85,7 +87,7 @@ public class MtkjpayApplication {
|
|||||||
log.info("""
|
log.info("""
|
||||||
|
|
||||||
📌 提示:
|
📌 提示:
|
||||||
- 前端代理地址: http://localhost:3000
|
- 前端地址: https://shopd.mtkj2025.com
|
||||||
- 后端API地址: {}
|
- 后端API地址: {}
|
||||||
- 图片上传接口: {}/product/upload/image
|
- 图片上传接口: {}/product/upload/image
|
||||||
- 商品管理接口: {}/product
|
- 商品管理接口: {}/product
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ server:
|
|||||||
|
|
||||||
# 应用配置(所有环境通用)
|
# 应用配置(所有环境通用)
|
||||||
app:
|
app:
|
||||||
# 前端访问地址(用于生成商品详情页URL等)
|
# 前端访问地址(已配置SSL证书,使用HTTPS和域名)
|
||||||
frontend:
|
frontend:
|
||||||
url: http://localhost:3000
|
url: https://shopd.mtkj2025.com
|
||||||
|
|
||||||
# 阿里云OSS相关配置(所有环境通用)
|
# 阿里云OSS相关配置(所有环境通用)
|
||||||
aliyun:
|
aliyun:
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ server:
|
|||||||
|
|
||||||
# 应用配置(所有环境通用)
|
# 应用配置(所有环境通用)
|
||||||
app:
|
app:
|
||||||
# 前端访问地址(用于生成商品详情页URL等)
|
# 前端访问地址(已配置SSL证书,使用HTTPS和域名)
|
||||||
frontend:
|
frontend:
|
||||||
url: http://localhost:3000
|
url: https://shopd.mtkj2025.com
|
||||||
|
|
||||||
# 阿里云OSS相关配置(所有环境通用)
|
# 阿里云OSS相关配置(所有环境通用)
|
||||||
aliyun:
|
aliyun:
|
||||||
|
|||||||
Reference in New Issue
Block a user