gateway
This commit is contained in:
@@ -17,102 +17,119 @@ spring:
|
||||
namespace: dev
|
||||
group: DEFAULT_GROUP
|
||||
config:
|
||||
enabled: false # 禁用Nacos配置中心,使用本地配置
|
||||
server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
|
||||
file-extension: yml
|
||||
namespace: dev
|
||||
group: DEFAULT_GROUP
|
||||
|
||||
# Gateway 路由配置(使用新的 webflux 配置路径)
|
||||
# Gateway 路由配置
|
||||
gateway:
|
||||
server:
|
||||
webflux:
|
||||
# 服务发现路由(自动路由)
|
||||
discovery:
|
||||
locator:
|
||||
enabled: false # 关闭自动路由,使用手动配置
|
||||
|
||||
# 手动配置路由
|
||||
routes:
|
||||
# ==================== 认证服务路由 ====================
|
||||
- id: auth-service
|
||||
uri: lb://auth-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/auth/**
|
||||
filters:
|
||||
# 不需要重写,直接转发保持原路径
|
||||
- name: RequestRateLimiter
|
||||
args:
|
||||
redis-rate-limiter.replenishRate: 100
|
||||
redis-rate-limiter.burstCapacity: 200
|
||||
# 服务发现路由(自动路由)
|
||||
discovery:
|
||||
locator:
|
||||
enabled: false # 关闭自动路由,使用手动配置
|
||||
|
||||
# 手动配置路由
|
||||
routes:
|
||||
# ==================== 认证服务路由 ====================
|
||||
- id: auth-service
|
||||
uri: lb://auth-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/auth/**
|
||||
filters:
|
||||
- StripPrefix=1 # 去掉前缀:/urban-lifeline/auth/login → /auth/login
|
||||
- name: RequestRateLimiter
|
||||
args:
|
||||
redis-rate-limiter.replenishRate: 100
|
||||
redis-rate-limiter.burstCapacity: 200
|
||||
|
||||
# ==================== 系统服务路由 ====================
|
||||
- id: system-service
|
||||
uri: lb://system-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/system/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
# ==================== 系统服务路由 ====================
|
||||
- id: system-service
|
||||
uri: lb://system-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/system/**
|
||||
|
||||
# ==================== 日志服务路由 ====================
|
||||
- id: log-service
|
||||
uri: lb://log-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/log/**
|
||||
|
||||
# ==================== 文件服务路由 ====================
|
||||
- id: file-service
|
||||
uri: lb://file-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/file/**
|
||||
|
||||
# ==================== 消息服务路由 ====================
|
||||
- id: message-service
|
||||
uri: lb://message-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/message/**
|
||||
|
||||
# ==================== 招投标服务路由 ====================
|
||||
- id: bidding-service
|
||||
uri: lb://bidding-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/bidding/**
|
||||
|
||||
# ==================== 平台服务路由 ====================
|
||||
- id: platform-service
|
||||
uri: lb://platform-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/platform/**
|
||||
|
||||
# ==================== 工单服务路由 ====================
|
||||
- id: workcase-service
|
||||
uri: lb://workcase-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/workcase/**
|
||||
|
||||
# ==================== 定时任务服务路由 ====================
|
||||
- id: crontab-service
|
||||
uri: lb://crontab-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/crontab/**
|
||||
|
||||
# ==================== AI Agent 服务路由 ====================
|
||||
- id: agent-service
|
||||
uri: lb://agent-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/agent/**
|
||||
|
||||
# 全局跨域配置
|
||||
globalcors:
|
||||
cors-configurations:
|
||||
'[/**]':
|
||||
allowedOriginPatterns: "*"
|
||||
allowedMethods:
|
||||
- GET
|
||||
- POST
|
||||
- PUT
|
||||
- DELETE
|
||||
- OPTIONS
|
||||
allowedHeaders: "*"
|
||||
allowCredentials: true
|
||||
maxAge: 3600
|
||||
# ==================== 日志服务路由 ====================
|
||||
- id: log-service
|
||||
uri: lb://log-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/log/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
# ==================== 文件服务路由 ====================
|
||||
- id: file-service
|
||||
uri: lb://file-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/file/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
# ==================== 消息服务路由 ====================
|
||||
- id: message-service
|
||||
uri: lb://message-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/message/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
# ==================== 招投标服务路由 ====================
|
||||
- id: bidding-service
|
||||
uri: lb://bidding-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/bidding/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
# ==================== 平台服务路由 ====================
|
||||
- id: platform-service
|
||||
uri: lb://platform-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/platform/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
# ==================== 工单服务路由 ====================
|
||||
- id: workcase-service
|
||||
uri: lb://workcase-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/workcase/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
# ==================== 定时任务服务路由 ====================
|
||||
- id: crontab-service
|
||||
uri: lb://crontab-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/crontab/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
# ==================== AI Agent 服务路由 ====================
|
||||
- id: agent-service
|
||||
uri: lb://agent-service
|
||||
predicates:
|
||||
- Path=/urban-lifeline/agent/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
||||
# 全局跨域配置
|
||||
globalcors:
|
||||
cors-configurations:
|
||||
'[/**]':
|
||||
allowedOriginPatterns: "*"
|
||||
allowedMethods:
|
||||
- GET
|
||||
- POST
|
||||
- PUT
|
||||
- DELETE
|
||||
- OPTIONS
|
||||
allowedHeaders: "*"
|
||||
allowCredentials: true
|
||||
maxAge: 3600
|
||||
datasource:
|
||||
# 按你的实际库名改一下,比如 urban-lifeline_system
|
||||
url: jdbc:postgresql://127.0.0.1:5432/urban_lifeline # 换成你的 PG 库名
|
||||
@@ -137,7 +154,7 @@ spring:
|
||||
# 认证配置
|
||||
auth:
|
||||
enabled: true
|
||||
gateway-mode: true
|
||||
# gateway-mode 是给下游微服务用的,gateway本身不需要此配置
|
||||
token-header: Authorization
|
||||
token-prefix: "Bearer "
|
||||
# 认证接口白名单(login/logout/captcha/refresh)
|
||||
|
||||
Reference in New Issue
Block a user