Spring cloud gateway 详解和配置使用(文章较长)
微服务网关 Spring Cloud Gateway
简介
官网地址:https://spring.io/projects/spring-cloud-gateway
官网guide:https://spring.io/guides/gs/gateway/
This project provides a library for building an API Gateway on top of Spring WebFlux. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.
Features
Spring Cloud Gateway features:
- Built on Spring Framework 5, Project Reactor and Spring Boot 2.0
- Able to match routes on any request attribute. 能够匹配任何请求属性的路由。
- Predicates and filters are specific to routes. 特定于路由的Predicates和filters。
- Circuit Breaker integration. 断路器的集成。
- Spring Cloud DiscoveryClient integration. Spring Cloud 服务发现客户端的集成。
- Easy to write Predicates and Filters. 编写Predicate和Filters简单。
- Request Rate Limiting. 请求速率的限制。
- Path Rewriting. 请求路径重写。
Spring Cloud Gateway & Nacos & Redis
Spring Cloud Gateway & Nacos & Redis实现服务注册中心、服务配置中心、网关路由、熔断、限流。
完整示例代码:
https://github.com/superHeroJLS/spring-cloud-nacos
网关相关配置在gateway子工程中
CentOS7安装Nacos及Nacos配置:
Nacos
CentOS7安装Redis:
Redis
常见问题
gateway-全局过滤器 GlobalFilter
Spring Cloud Gateway:GlobalFilter和GatewayFilter的区别与联系
Spring Cloud Gateway的Gateway Filter和Global Filter路由实战
