八:Spring Cloud 之服务路由网关-zuul

本文介绍了Spring Cloud中的Zuul作为服务路由网关的作用,详细讲解了如何配置和使用Zuul进行动态路由、监控、弹性与安全性设置。通过模块关系图谱展示了涉及的服务,包括Eureka Server、服务提供者、Feign客户端和Ribbon客户端。还阐述了Zuul的Filter类型,包括pre、route、post和error,以及如何自定义过滤器进行请求处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 简介

Zuul is the front door for all requests from devices and web sites to the backend of the Netflix streaming application. As an edge service application, Zuul is built to enable dynamic routing, monitoring, resiliency and security. It also has the ability to route requests to multiple Amazon Auto Scaling Groups as appropriate.


Zuul 是在云平台上提供动态路由,监控,弹性,安全等边缘服务的框架。Zuul 相当于是设备和 Netflix 流应用的 Web 网站后端所有请求的前门。

2. 代码实现

2.1涉及的模块及关系图谱

2.1.1 涉及的模块

  • eureka-server-singleton:服务注册中心,端口8761
  • eureka-service: 服务提供者,通过profile指定不同端口模拟一组微服务,端口8762、8763
  • eureka-service-feign:通过Feign调用服务提供者提供的服务
  • eureka-service-ribbon:通过Feign调用服务提供者提供的服务
  • eureka-service-zuul:服务路由功能,实现请求路由,网关功能

2.1.2 模块关系图谱

模块关系图

2.2 源代码

2.2.1 Github地址

https://github.com/andyChenHuaYing/spring-cloud-demo

2.2.2 切换

通过tag切换git tag -d v1.0,若想修改,可根据此tag创建新的分支。

2.3 eureka-server-singleton

Spring Cloud 之服务发现与调用-Ribbon#2.3 eureka-server-singleton 没有任何区别

2.4 eureka-service

Spring Cloud 之服务发现与调用-Ribbon#2.4 eureka-service 没有任何区别

2.5 eureka-service-feign

五:Spring Cloud 之服务发现与调用-Feign#2.5 eureka-service-feign没有任何区别

2.6 eureka-service-ribbon

四:Spring Cloud 之服务发现与调用-Ribbon#2.5 eureka-service-ribbon 没有任何区别

2.7 eureka-service-zuul

2.7.1 整体实现

  1. pom.xml中引入spring-cloud-starter-netflix-eureka-clientspring-cloud-starter-netflix-zuul依赖
  2. application.yml中指定配置项
    1. 端口:8768
    2. 应用名称:eureka-serivce-zu
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值