# 观澜 v2 · Java 网关(Spring Cloud Gateway + OAuth2/JWT 校验 + Nacos 可选) # # 端口 28085:与现 Python 网关 28084 **并存**,迁移期按前缀灰度切换(用户令:可回滚)。 # 路由表直接写在配置里 —— 单体/离线模式不依赖注册中心;要接 Nacos 时把 guanlan.nacos.enabled 置 true。 server: port: 28085 spring: application: name: guanlan-gateway cloud: gateway: # 统一入口的路由(与现 Python 网关 gateway.py 的前缀表一一对应) routes: - id: algorithm uri: http://127.0.0.1:18050 predicates: - Path=/algorithm/** filters: - StripPrefix=1 - id: web uri: http://127.0.0.1:28110 predicates: - Path=/web/** filters: - StripPrefix=1 - id: detail uri: http://127.0.0.1:18033 predicates: - Path=/detail/** filters: - StripPrefix=1 - id: cms uri: http://127.0.0.1:18020 predicates: - Path=/cms/** filters: - StripPrefix=1 httpclient: connect-timeout: 5000 response-timeout: 120s # Nacos 服务发现(可选;enabled=false 时单体模式照跑) nacos: discovery: enabled: ${guanlan.nacos.enabled:false} server-addr: ${guanlan.nacos.addr:127.0.0.1:8848} guanlan: nacos: enabled: false addr: 127.0.0.1:8848 # 与业务后端**同一密钥**(HMAC):网关侧只做校验,签发在业务后端 /java/token jwt: secret: ${GUANLAN_JWT_SECRET:guanlan-offline-hmac-secret-change-me-0123456789abcdef} issuer: guanlan management: endpoints: web: exposure: include: health,info,gateway logging: level: root: INFO com.guanlan: INFO org.springframework.cloud.gateway: INFO