Spring-cloud-netflix: Zuul routing config - multiple web paths for serviceid

Created on 25 Feb 2015  路  11Comments  路  Source: spring-cloud/spring-cloud-netflix

I am trying to route multiple web paths to be routed to a single service. I might need this for the future.

zuul:
  ignored-services: "*"
  routes:
    stores:
      path: 
        /stores/** (also tried - /stores as per spring boot yaml docs)
        /stores1/**

The routes look like this:

{
    "/stores/** /stores1/**": "stores"
}

Does it make sense to support this capability?

enhancement

Most helpful comment

See http://stackoverflow.com/questions/28662237/multiple-zuul-routes-to-one-service/28665239

zuul:
  routes:
    myserver_mypath:
      path: /mypath/**
      serviceId: myserver
    myserver_another_path:
      path: /anotherpath/**
      serviceId: myserver

works

All 11 comments

I'm not sure I'd ever use that feature. What's your use case?

Anyway you can always create 2 routes, e.g.

zuul:
  routes:
    stores: /stores/**
    stores1: /stores1/**

My goal is a proof of concept for:

  • zuul proxy for multiple api-s or versions
    /api/v1/...
    and
    /api/v2/...
  • backwards compatibility for endpoints
    Integrators have a built in url which we need to maintain along side the new url-s, but both should point to the same service

Thanks

See http://stackoverflow.com/questions/28662237/multiple-zuul-routes-to-one-service/28665239

zuul:
  routes:
    myserver_mypath:
      path: /mypath/**
      serviceId: myserver
    myserver_another_path:
      path: /anotherpath/**
      serviceId: myserver

works

Thank you

I have a question. In case, I don't use serviceId because I don't use Eureka, I only use Zuul for routing, how can I route multiple URLs to 1 service? Thank you!

Hi @duongvu89 !

Thanks for your question. I have one though myself - could we please post such questions to stackoverflow? We're trying to treat Github issues as a place where we keep issues.

Coming back to your question. Check out the docs: http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html#spring-cloud-ribbon-without-eureka

@marcingrzejszczak Thank you for your suggestion. Actually, I am working on a project that previously built by another person, he didn't use Netflix OSS, he use Akka, Zookeeper instead. Now, I take over the project and has successfully integrated Zuul for gateway server.
Now I think I will gradually change to use Netflix solution as it would be a better solution & less complexity. The project has just been developed for several months so changing is possible. Would you mind give me an advice for the changes? Thanks a lot!

@duongvu89 let's maybe move to Gitter? https://gitter.im/spring-cloud/spring-cloud

Thank you!

Hi @spencergibb

routing different paths works fine with your example, however I need to set different read timeouts for the routes which does not seam to work. When I use:

zuul:
  routes:
    myserver_mypath:
      path: /mypath/**
      serviceId: myserver
    myserver_another_path:
      path: /anotherpath/**
      serviceId: myserver

myserver_mypath:
  ribbon:
    readTimeout: someHighValue

hystrix:
  command:
    myserver_mypath:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: someHighValue

The timout for that specific path has no effect. If I use the serviceId myserver instead of myserver_mypath it does work.

Is there no possibility to configure different timeouts for different paths on the same service?

@duongvu89 as all the Spring-Cloud-Netflix projects other than Eureka have been moved to maintenance mode, I wouldn't really recommend switching to this stack. Rather, make a transition to use SC Gateway, SC LoadBalancer and SC CircuitBreaker (coming as part of the Hoxton release train).

Was this page helpful?
0 / 5 - 0 ratings