网关的核心概念:
- 路由
- 谓词
- 过滤器(11个)
spring:cloud:gateway:enabled: truediscovery:locator:enabled: true #开启动态路由lower-case-service-id: trueroutes:- id: trendsi-trace1uri: lb://trendsi-trace1predicates:- Method=GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS,TRACE- Path=/api/tr11ace/**filters:- StripPrefix=2httpclient:connect-timeout: 100000max-header-size: 102400max-initial-line-length: 102400pool:acquire-timeout: 20000max-connections: 5000max-idle-time: 30smax-life-time: 30sname: proxytype: fixedresponse-timeout: 10sloadbalancer:retry:enabled: truesentinel:enabled: truetransport:dashboard: localhost:8858port: 8719heartbeat-interval-ms: 1000filter:enabled: truemetric:charset: UTF-8eager: truelog:dir: ./logs/${spring.application.name}/sentinelscg:fallback:mode: responseresponse-status: 200response-body: "{\"code\":\"11005\",\"message\":\"请求太多了\"}"xy:enable: truemvc-interceptor-enable: truetotal-interceptor-enable: false# websocket:# proxy-ping: false# max-frame-payload-length: 10000# proxy:# host:# non-proxy-hosts-pattern:# password:# port:# username:# ssl:# close-notify-flush-timeout:# close-notify-read-timeout:# default-configuration-type: tcp# handshake-timeout:# key-password:# key-store:# key-store-password:# key-store-provider:# key-store-type:# trusted-x509-certificates:# use-insecure-trust-manager: false# wiretap: true# refresh:# enabled: truemanagement:endpoints:web:exposure:include: '*'endpoint:health:show-details: alwayslogging:level:org.springframework.cloud.gateway: infoinfo:app.name: ${spring.application.name}li.name: www.li.combuild.artifactId: '@project.artifactId@'build.version: '@project.version@'gateway:config:black-url-list:- /asd/asdasd/asdas- /asd/asdasd/asdas1- /asd/asdasd/asdas2black-ip-list:- 172.10.23.55- 172.10.23.56- 172.10.23.57
/module-api/**
StripPrefix=1
1标识转发时过滤/module-api
过滤器
共提供31个过滤器。
谓词
共提供11个谓词。
After
Before
Between
Cookie
Header
Method
Path(常用)
Host
Query
RemoteAddr
Weight
自定义谓词
RoutePredicateFactory
rpc 泛化调用
gateway 开源版本当前转发的是http请求,对于dubbo rpc请求,需要自行研发。
TODO
