Files
nxxmdata/government-backend/nginx-config-check.md

64 lines
1.7 KiB
Markdown
Raw Normal View History

2025-10-17 17:29:11 +08:00
# Nginx配置检查说明
## 问题分析
### 当前状态
- ✅ 后端服务正常:`http://localhost:5352/api/government/departments` 返回200
- ✅ 登录接口正常:`https://ad.ningmuyun.com/api/government/auth/login` 返回401
- ❌ 其他接口404`https://ad.ningmuyun.com/api/government/departments` 返回404
### 问题根因
nginx配置中的 `location ^~ /api/government/` 规则没有正确工作。
### 当前nginx配置
```nginx
# 政府认证API代理 - 处理登录等认证接口优先级高于通用government代理
location ^~ /api/government/auth/ {
proxy_pass http://localhost:5352/api/auth/;
# ... CORS配置
}
# 政府API代理 - 处理其他政府相关接口
location ^~ /api/government/ {
proxy_pass http://localhost:5352/api/government/;
# ... CORS配置
}
```
### 可能的问题
1. **nginx配置语法错误** - 需要检查配置语法
2. **nginx服务未重启** - 配置修改后需要重启
3. **location规则冲突** - 可能有其他规则干扰
4. **proxy_pass配置错误** - 路径映射不正确
## 解决步骤
### 1. 检查nginx配置语法
```bash
sudo nginx -t
```
### 2. 重启nginx服务
```bash
sudo systemctl reload nginx
# 或者
sudo systemctl restart nginx
```
### 3. 检查nginx错误日志
```bash
sudo tail -f /var/log/nginx/error.log
```
### 4. 检查nginx访问日志
```bash
sudo tail -f /var/log/nginx/ad.ningmuyun.com.access.log
```
## 预期结果
修复后,以下接口应该正常工作:
-`https://ad.ningmuyun.com/api/government/auth/login` (登录)
-`https://ad.ningmuyun.com/api/government/departments` (部门列表)
-`https://ad.ningmuyun.com/api/government/data-center` (数据中心)
-`https://ad.ningmuyun.com/api/government/market-price` (市场价格)