Search code examples
spring-bootspring-cloudnetflix-zuul

Spring Boot Zuul : Map Multiple Route URLs


We are using Spring Boot with Zuul Proxy to forward the API requests to APIs. Sample Configuration is as below:

zuul.routes.common.url=http://10.0.0.1:8081/common
zuul.routes.meta.url=http://10.0.0.2:8082/meta

Every thing works fine with this. For balancing our load and utilising underlying servers effeciently, we would like to specify multiple URLs as part of the configuration and enable request forwarding for one of the URL. To be precise, we would like to configure the proxy config as given below by providing comma delimited list of endpoints which can handle the requests.

zuul.routes.common.url=http://10.0.0.1:8081/common,http://10.0.0.11:8081/common
zuul.routes.meta.url=http://10.0.0.2:8082/meta,http://10.0.0.12:8082/meta

But unfortunately, such config is resulting in "Resource not found Error".

Questions:

  1. Is this a possible configuration?
  2. if not, Is it possible to achieve this by any other means?

Regards, Manjunath

Edit : Answer

Its not possible to configure multiple URLs just with Zuul. Request need to be load balanced using Ribbon. Here is the sample configuration with ribbon:

zuul.routes.common.path=/**
zuul.routes.common.serviceId=common
common.ribbon.listOfServers=http://10.0.0.1:8081/common,http://10.0.0.2:8081/common

Solution

  • You want to use Ribbon, and the property client.ribbon.listOfServers. Here is a quick example

    zuul:
      routes:
        users:
          path: /myusers/**
          serviceId: users
    
    ribbon:
      eureka:
        enabled: false
    
    users:
      ribbon:
        listOfServers: example.com,google.com