问题:fund-gateway 和 fund-sys 的 application.yml 缺少 tenant.routing 配置 修改内容: 1. fund-sys/application.yml - 添加 tenant.routing 配置 - 配置 VIP 租户列表 (TENANT_VIP_001, TENANT_VIP_002) - 配置共享服务列表 2. fund-gateway/application.yml - 添加 Nacos 服务发现配置 - 路由改为 lb:// 协议使用负载均衡 - 添加全局跨域配置 - 添加 tenant.routing 配置 - 添加负载均衡日志级别
157 lines
3.5 KiB
YAML
157 lines
3.5 KiB
YAML
server:
|
|
port: 8000
|
|
|
|
spring:
|
|
application:
|
|
name: fund-gateway
|
|
|
|
# Redis配置(用于限流)
|
|
data:
|
|
redis:
|
|
host: localhost
|
|
port: 6379
|
|
password: zjf@123456
|
|
database: 1
|
|
|
|
cloud:
|
|
compatibility-verifier:
|
|
enabled: false
|
|
|
|
# Nacos 服务发现
|
|
nacos:
|
|
discovery:
|
|
server-addr: localhost:8848
|
|
namespace: fund-platform
|
|
group: DEFAULT_GROUP
|
|
username: nacos
|
|
password: nacos
|
|
|
|
# Sentinel配置
|
|
sentinel:
|
|
transport:
|
|
dashboard: localhost:8080 # Sentinel Dashboard地址(可选)
|
|
port: 8719 # Sentinel客户端端口
|
|
eager: true # 服务启动时立即初始化
|
|
|
|
# 负载均衡配置
|
|
loadbalancer:
|
|
enabled: true
|
|
cache:
|
|
enabled: false # 开发环境禁用缓存便于调试
|
|
|
|
gateway:
|
|
# 默认限流配置
|
|
default-filters:
|
|
- name: RequestRateLimiter
|
|
args:
|
|
redis-rate-limiter.replenishRate: 100 # 每秒补充令牌数
|
|
redis-rate-limiter.burstCapacity: 200 # 令牌桶最大容量
|
|
key-resolver: "#{@ipKeyResolver}"
|
|
|
|
# 全局跨域配置
|
|
globalcors:
|
|
cors-configurations:
|
|
'[/**]':
|
|
allowedOriginPatterns: "*"
|
|
allowedMethods: "*"
|
|
allowedHeaders: "*"
|
|
allowCredentials: true
|
|
maxAge: 3600
|
|
|
|
routes:
|
|
# 系统管理服务 (使用负载均衡)
|
|
- id: fund-sys
|
|
uri: lb://fund-sys
|
|
predicates:
|
|
- Path=/sys/**
|
|
filters:
|
|
- StripPrefix=1
|
|
|
|
# 客户管理服务
|
|
- id: fund-cust
|
|
uri: lb://fund-cust
|
|
predicates:
|
|
- Path=/cust/**
|
|
filters:
|
|
- StripPrefix=1
|
|
|
|
# 项目管理服务
|
|
- id: fund-proj
|
|
uri: lb://fund-proj
|
|
predicates:
|
|
- Path=/proj/**
|
|
filters:
|
|
- StripPrefix=1
|
|
|
|
# 用款申请服务
|
|
- id: fund-req
|
|
uri: lb://fund-req
|
|
predicates:
|
|
- Path=/req/**
|
|
filters:
|
|
- StripPrefix=1
|
|
|
|
# 支出管理服务
|
|
- id: fund-exp
|
|
uri: lb://fund-exp
|
|
predicates:
|
|
- Path=/exp/**
|
|
filters:
|
|
- StripPrefix=1
|
|
|
|
# 收款管理服务
|
|
- id: fund-receipt
|
|
uri: lb://fund-receipt
|
|
predicates:
|
|
- Path=/receipt/**
|
|
filters:
|
|
- StripPrefix=1
|
|
|
|
# 报表服务
|
|
- id: fund-report
|
|
uri: lb://fund-report
|
|
predicates:
|
|
- Path=/report/**
|
|
filters:
|
|
- StripPrefix=1
|
|
|
|
# 文件服务
|
|
- id: fund-file
|
|
uri: lb://fund-file
|
|
predicates:
|
|
- Path=/file/**
|
|
filters:
|
|
- StripPrefix=1
|
|
|
|
logging:
|
|
level:
|
|
org.springframework.cloud.gateway: DEBUG
|
|
com.fundplatform.common.loadbalancer: DEBUG
|
|
|
|
# 多租户路由配置
|
|
tenant:
|
|
routing:
|
|
enabled: true
|
|
tenant-header: X-Tenant-Id
|
|
tenant-group-header: X-Tenant-Group
|
|
group-separator: TENANT_
|
|
default-tenant-id: "1"
|
|
shared-services:
|
|
- fund-gateway
|
|
- fund-report
|
|
- fund-file
|
|
services:
|
|
fund-sys:
|
|
vip-tenants:
|
|
- TENANT_VIP_001
|
|
- TENANT_VIP_002
|
|
fallback-to-shared: true
|
|
fund-cust:
|
|
vip-tenants:
|
|
- TENANT_VIP_001
|
|
fallback-to-shared: true
|
|
fund-proj:
|
|
vip-tenants:
|
|
- TENANT_VIP_001
|
|
fallback-to-shared: true
|