提交 b050fd7a authored 作者: 陈世营's avatar 陈世营

【修改】增加网关限流规则

上级 28fa1e4c
......@@ -10,4 +10,106 @@ logging:
org.springframework.cloud.gateway: trace
org.springframework.http.server.reactive: debug
org.springframework.web.reactive: debug
reactor.ipc.netty: debug
\ No newline at end of file
reactor.ipc.netty: debug
spring:
application:
name: gateway-service
main:
allow-bean-definition-overriding: true
cloud:
# 使用 Naoos 作为服务注册发现
nacos.discovery:
server-addr: 47.114.50.99:8010
namespace: 46c2400a-5773-4c26-be68-2e90a673259b
gateway:
enabled: true
discovery:
locator:
lower-case-service-id: true
routes:
# 采用自定义路由 ID(有固定用法,不同的 id 有不同的功能,详见:https://cloud.spring.io/spring-cloud-gateway/2.0.x/single/spring-cloud-gateway.html#gateway-route-filters)
# - id: ORDER-SERVICE-TTT
# # 采用 LoadBalanceClient 方式请求,以 lb:// 开头,后面的是注册在 Nacos 上的服务名
# uri: lb://order-service
# # Predicate 翻译过来是“谓词”的意思,必须,主要作用是匹配用户的请求,有很多种用法
# predicates:
# - Path=/api-order/**
# filters:
# - StripPrefix=1
# - id: STORAGE-SERVICE_TTTT
# uri: lb://storage-service
# predicates:
# - Path=/api-storage/**
# filters:
# - StripPrefix=1
- id: loit-portal-id
uri: lb://loit-portal
predicates:
- Path=/api-portal/**
filters:
- StripPrefix=1
logoutSign: true
sentinel:
# datasource.ds2.file:
# file: "classpath: gateway-service-sentinel-gateway"
# ruleType: gw-flow
# datasource.ds1.file:
# file: "classpath: gateway-service-sentinel-api"
# ruleType: gw-api-group
# enabled: true
datasource:
ds2:
nacos:
data-id: ${spring.application.name}-sentinel-gateway
group-id: DEFAULT_GROUP
rule-type: gw-flow
server-addr: 47.114.50.99:8010
namespace: 46c2400a-5773-4c26-be68-2e90a673259b
data-type: json
ds1:
nacos:
data-id: ${spring.application.name}-sentinel-api
group-id: DEFAULT_GROUP
rule-type: gw-api-group
server-addr: 47.114.50.99:8010
namespace: 46c2400a-5773-4c26-be68-2e90a673259b
data-type: json
ds3:
nacos:
server-addr: 47.114.50.99:8010
namespace: 46c2400a-5773-4c26-be68-2e90a673259b
dataId: ${spring.application.name}-degrade-rules
data-type: json
rule-type: degrade
# datasource.ds3.file:
# file: "classpath: gateway-service-degrade-rules"
# ruleType: degrade
# dataType: json
## 应用与Sentinel控制台交互的端口,应用本地会起一个该端口占用的HttpServer
transport:
## Sentinel 控制台地址
dashboard: localhost:8090
## 应用与Sentinel控制台的心跳间隔时间
heartbeat-interval-ms: 10000
port: 8719
filter:
enabled: true
scg.fallback:
## Spring Cloud Gateway 熔断后的响应模式(选择 redirect or response)
mode: response
## Spring Cloud Gateway 响应模式为 'response' 模式对应的响应码
response-status: 444
## Spring Cloud Gateway 响应模式为 'response' 模式对应的响应内容
response-body: 系统繁忙请稍后再试
scg:
order: -100
# 断路器设置
feign:
sentinel:
enabled: true
spring.profiles.active=dev
spring.application.name=gateway-service
# Nacos \u914D\u7F6E\u4E2D\u5FC3\u5730\u5740http://39.100.254.140/
spring.cloud.nacos.config.server-addr=47.114.50.99:8010
spring.cloud.nacos.config.namespace=46c2400a-5773-4c26-be68-2e90a673259b
spring.cloud.nacos.config.file-extension=yaml
\ No newline at end of file
spring:
application:
name: gateway-service
main:
allow-bean-definition-overriding: true
cloud:
# 使用 Naoos 作为服务注册发现
nacos.discovery:
server-addr: 39.100.254.140:8103
namespace: 3ac84119-5558-4bf8-b309-034dd0e458e0
gateway:
enabled: true
discovery:
locator:
lower-case-service-id: true
routes:
# 采用自定义路由 ID(有固定用法,不同的 id 有不同的功能,详见:https://cloud.spring.io/spring-cloud-gateway/2.0.x/single/spring-cloud-gateway.html#gateway-route-filters)
- id: ORDER-SERVICE-TTT
# 采用 LoadBalanceClient 方式请求,以 lb:// 开头,后面的是注册在 Nacos 上的服务名
uri: lb://order-service
# Predicate 翻译过来是“谓词”的意思,必须,主要作用是匹配用户的请求,有很多种用法
predicates:
- Path=/api-order/**
filters:
- StripPrefix=1
- id: STORAGE-SERVICE_TTTT
uri: lb://storage-service
predicates:
- Path=/api-storage/**
filters:
- StripPrefix=1
sentinel:
datasource.ds2.nacos:
server-addr: 39.100.254.140:8103
namespace: 3ac84119-5558-4bf8-b309-034dd0e458e0
data-id: ${spring.application.name}-sentinel-gateway
data-type: json
group-id: DEFAULT_GROUP
ruleType: gw-flow
datasource.ds1.nacos:
server-addr: 39.100.254.140:8103
namespace: 3ac84119-5558-4bf8-b309-034dd0e458e0
data-id: ${spring.application.name}-sentinel-api
data-type: json
group-id: DEFAULT_GROUP
ruleType: gw-api-group
## 应用与Sentinel控制台交互的端口,应用本地会起一个该端口占用的HttpServer
transport:
## Sentinel 控制台地址
dashboard: localhost:8080
## 应用与Sentinel控制台的心跳间隔时间
heartbeat-interval-ms: 60000
filter:
enabled: true
scg.fallback:
## Spring Cloud Gateway 熔断后的响应模式(选择 redirect or response)
mode: response
## Spring Cloud Gateway 响应模式为 'response' 模式对应的响应码
response-status: 444
## Spring Cloud Gateway 响应模式为 'response' 模式对应的响应内容
response-body: 系统繁忙请稍后再试
scg:
order: -100
\ No newline at end of file
[
{
"resource": "loit-portal-api",
"count": 50,
"grade": 0,
"timeWindow": 100
}
]
\ No newline at end of file
[{
"apiName": "loit-portal-api",
"predicateItems": [
{
"pattern": "/api-portal/**",
"matchStrategy": 1
}
]
}
]
[{
"resource": "loit-portal-api",
"count": 1,
"intervalSec": 1
}
]
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论