1. 业务服务配置(fund-cust/proj/req/exp/receipt)
- 添加 Nacos metadata.tenant-id 配置
- 添加 tenant.routing 配置
- 移除无效的 feign.fund-sys.url 配置
2. 共享服务配置(fund-report/file)
- 添加 tenant.routing.enabled: false
- 共享服务不需要租户路由
3. Gateway 配置清理
- 移除过时的 tenant-group-header 配置
- 移除过时的 group-separator 配置
4. 删除 Docker 配置文件
- 删除 fund-sys/application-docker.yml
- 删除 fund-gateway/application-docker.yml
配置规范:
业务服务: tenant.routing.enabled=true, metadata.tenant-id=${TENANT_ID:}
共享服务: tenant.routing.enabled=false
144 lines
3.3 KiB
YAML
144 lines
3.3 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
|
||
|
||
# 多租户路由配置(Gateway 全局配置)
|
||
tenant:
|
||
routing:
|
||
enabled: true
|
||
tenant-header: X-Tenant-Id
|
||
default-tenant-id: "1"
|
||
# 共享服务列表(不需要租户路由的服务)
|
||
shared-services:
|
||
- fund-gateway
|
||
- fund-report
|
||
- fund-file
|
||
# 默认回退策略
|
||
fallback-to-shared: true
|