Spring Cloud Zuul/Eureka dynamic route

一笑奈何 提交于 2020-01-28 21:00:02

问题


I am using spring cloud eureka and spring cloud zuul proxy and i was wondering if there is any way to add dymanic zuul routes when a new service is register in eureka server or the only way to add a route is edit the application.yml file and restart the spring zuul application

zuul:
  ignoredPatterns: /**/admin/**
  routes:
    users: /myusers/**

回答1:


If your Zuul server is also EurekaClient (use @EnableDiscoveryClient annotation) it will discover all the services and automatically will create routes.

Ex. Zuul server is zuul.mydomain.com Eureka has 2 services registered with it : orders and accounts

Then Zuul will automatically have two routes Zuul.mydomain.com/orders and Zuul.mydomain.com/accounts

And this will forward to particular service. It will also automatically load balance calls for you if services run on multiple machines.



来源:https://stackoverflow.com/questions/37054643/spring-cloud-zuul-eureka-dynamic-route

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!