动态发现路由的Zuul代理
Zuul proxy that discovers routes dynamically
我有一个简单的 Zuul 应用程序,它在 application.yml 中有一个路由可以路由到我的微服务。有效。
然而,我正在寻找的是一个更动态的解决方案,我可以动态地连接路由,通过代码或者在构建期间发布到一些 Zuul 端点(可能通过使用 springfox 和来自微服务)。我找不到 Zuul 的 API。
我对 Eureka 有所了解,这似乎是一种通过发现来抽象路由的解决方案。但是,我很好奇是否有不引入 Eureka 的解决方案。如果有一种方法可以在构建期间在 Zuul 中连接这些路由,而不是每次都必须编辑 application.yml。
提前致谢。
如果您选择 Eureka,这实际上可以 ootb。 spring 云中打包的 Zuul 将使用其名称自动公开每个服务。因此,如果您在 Eureka 中注册了一个名为 users
的服务,Zuul 默认会自动创建一个路由 /users
转发到实例。这将只允许简单的 url 结构,但应该可以解决您的问题。
By convention, a service with the ID "users", will receive requests from the proxy located at /users (with the prefix stripped). The proxy uses Ribbon to locate an instance to forward to via discovery, and all requests are executed in a hystrix command, …
我实际上正在编辑关于这个确切主题的博客 post(使用 Spring Cloud Zuul Server 的路由和过滤)但是源代码有现在可用并工作了一段时间。随意作为参考:
- https://bitbucket.org/asimio/zuulserver
- https://bitbucket.org/asimio/discoveryserver(如果路由配置了 serviceIds)
- https://bitbucket.org/asimio/demo-config-properties/src(Zuul-Server-refreshable.yml 其中路由是动态更新的)。
查看可刷新的 Spring
配置文件设置。此 Zuul
设置适用于硬编码路由 url 或使用 Eureka
.
发现
它还充当 Spring Cloud Config 客户端,以便可以通过 Git 动态更新路由,这在另一篇博客 post 中也有介绍:Refreshable Configuration using Spring Cloud Config Server, Spring Cloud Bus, RabbitMQ and Git .
我有一个简单的 Zuul 应用程序,它在 application.yml 中有一个路由可以路由到我的微服务。有效。
然而,我正在寻找的是一个更动态的解决方案,我可以动态地连接路由,通过代码或者在构建期间发布到一些 Zuul 端点(可能通过使用 springfox 和来自微服务)。我找不到 Zuul 的 API。
我对 Eureka 有所了解,这似乎是一种通过发现来抽象路由的解决方案。但是,我很好奇是否有不引入 Eureka 的解决方案。如果有一种方法可以在构建期间在 Zuul 中连接这些路由,而不是每次都必须编辑 application.yml。
提前致谢。
如果您选择 Eureka,这实际上可以 ootb。 spring 云中打包的 Zuul 将使用其名称自动公开每个服务。因此,如果您在 Eureka 中注册了一个名为 users
的服务,Zuul 默认会自动创建一个路由 /users
转发到实例。这将只允许简单的 url 结构,但应该可以解决您的问题。
By convention, a service with the ID "users", will receive requests from the proxy located at /users (with the prefix stripped). The proxy uses Ribbon to locate an instance to forward to via discovery, and all requests are executed in a hystrix command, …
我实际上正在编辑关于这个确切主题的博客 post(使用 Spring Cloud Zuul Server 的路由和过滤)但是源代码有现在可用并工作了一段时间。随意作为参考:
- https://bitbucket.org/asimio/zuulserver
- https://bitbucket.org/asimio/discoveryserver(如果路由配置了 serviceIds)
- https://bitbucket.org/asimio/demo-config-properties/src(Zuul-Server-refreshable.yml 其中路由是动态更新的)。
查看可刷新的 Spring
配置文件设置。此 Zuul
设置适用于硬编码路由 url 或使用 Eureka
.
它还充当 Spring Cloud Config 客户端,以便可以通过 Git 动态更新路由,这在另一篇博客 post 中也有介绍:Refreshable Configuration using Spring Cloud Config Server, Spring Cloud Bus, RabbitMQ and Git .