|
@@ -6,11 +6,10 @@ spring:
|
|
cloud:
|
|
cloud:
|
|
nacos:
|
|
nacos:
|
|
discovery:
|
|
discovery:
|
|
- server-addr: ${nacos.address}
|
|
|
|
- group: ${nacos.group}
|
|
|
|
- namespace: ${nacos.namespace}
|
|
|
|
- username: ${nacos.username}
|
|
|
|
- password: ${nacos.password}
|
|
|
|
|
|
+ server-addr: 192.168.3.206:8848
|
|
|
|
+ namespace:
|
|
|
|
+ username:
|
|
|
|
+ password:
|
|
metadata: # 保证微服务5s内能快速响应上线线
|
|
metadata: # 保证微服务5s内能快速响应上线线
|
|
preserved.heart.beat.interval: 1000 # 该实例在客户端上报心跳的间隔时间,单位为毫秒,默认为5s
|
|
preserved.heart.beat.interval: 1000 # 该实例在客户端上报心跳的间隔时间,单位为毫秒,默认为5s
|
|
preserved.heart.beat.timeout: 5000 # 该实例在不发送心跳后,从健康到不健康的时间,单位为毫秒,默认为15s
|
|
preserved.heart.beat.timeout: 5000 # 该实例在不发送心跳后,从健康到不健康的时间,单位为毫秒,默认为15s
|
|
@@ -27,12 +26,17 @@ spring:
|
|
response-timeout: 55s
|
|
response-timeout: 55s
|
|
routes:
|
|
routes:
|
|
# 配置路由,可以配置多个
|
|
# 配置路由,可以配置多个
|
|
- # ESB请求接入 在过滤器中动态修改URI 参数
|
|
|
|
- - id: trans-service-from-esb # 自定义路由的ID 保持唯一
|
|
|
|
- uri: lb://act-trans-service # 目标服务地址。动态路由 这里使用服务名的方式,gateway会帮我们去注册中心中获取服务列表
|
|
|
|
- predicates: # 路由条件,这里使用了Path作为路由条件(断言)
|
|
|
|
- - Path=/esb/inbound
|
|
|
|
- filters: # 配置路由过滤器
|
|
|
|
- - RewritePath=/esb/inbound, /gateway/front
|
|
|
|
|
|
+ - id: BUSINESS-OAUTH2 # 自定义路由的ID 保持唯一
|
|
|
|
+ # 采用 LoadBalanceClient 方式请求,以 lb:// 开头,后面的是注册在 Nacos 上的服务名
|
|
|
|
+ #https://www.jianshu.com/p/9994b2da8645 LoadBalanceClient解释
|
|
|
|
+ uri: lb://business-oauth2
|
|
|
|
+ # Predicate 翻译过来是“谓词”的意思,必须,主要作用是匹配用户的请求,有很多种用法
|
|
|
|
+ predicates:
|
|
|
|
+ # 路径匹配,以 api 开头,直接配置是不生效的,看 filters 配置
|
|
|
|
+ - Path=/api/user/**
|
|
|
|
+ filters:
|
|
|
|
+ # 前缀过滤,默认配置下,我们的请求路径是 http://localhost:8888/business-oauth2/** 这时会路由到指定的服务
|
|
|
|
+ # 此处配置去掉 1 个路径前缀,再配置上面的 Path=/api/**,就能按照 http://localhost:8888/api/** 的方式访问了
|
|
|
|
+ - StripPrefix=1
|
|
|
|
|
|
|
|
|