Hi,

I want to confirm on the approach which I have found , to used ZUUL to route to existing services without prefixing with serviceId.

I want to know if this is the recommended option or is there a better way to do this.

I want to route to existing downstream services without prefixing them with the serviceId which I understand helps in mapping to the service during routing.

I want this because I do not want any existing clients (UI Apps/Services) to be impacted because of this change or prefixing with serviceId , except for the host and port change.

I have an existing downstream service in the format as below url, http://{servicehost}:{servicePort}/{contextPath}/{endpointSpecificPath}

For eg, with url's as below,

--Fetch Specific Employee details
http://localhost:5080/employeeService/1

--Fetch All Employee Details
http://localhost:5080/employeeService

With ZUUL default routing I see I have to route them with the ZUUL Proxy url's as below,

http://zuulhost:zuulport/employee-service/employeeService/1
http://zuulhost:zuulport/employee-service/employeeService

The "employee-service" is the serviceId of the service when registering with service registry.

I made the below ZUUL route and with that I was able to route without prefixing with "serviceID".

zuul:
 ignored-services: "*"
 routes:
     employee-service:
          path: /employeeService/**
          serviceId: employee-service
          strip-prefix: false

When I add "strip-prefix" value as "false" at the route level, I am able to route to my downstream service as below,

http://zuulhost:zuulport/employeeService/1
http://zuulhost:zuulport/employeeService

But, I am now forced to add a route rule for each of my existing services and any new services which I intend to add in the future.

I want to know if this is the recommended approach because, that would mean I repeat the strip-prefix for each and every route mapping for each service.

Also, I have now more effort to do , as I have to dynamically refresh the zuul routes by injecting route updates for every service added using Spring Cloud Config Service and @RefreshScope annotation for zuul.properties bean.

It seems I have to use Spring Cloud Config and add routes for every service which I do not want to prefix with serviceId or anything. This I feel is more effort/overhead as Spring Cloud Config is another service I have to maintain in addition to Eureka and Zuul. But, I do see the benefits of using it.

So, would like to know if this is only way I can achieve my requirement of not prefixing with serviceId when using ZUUL or is there a better and simpler way without impacting existing clients.

Thanks, Sridhar

Comment From: spencergibb

That would be the recommended way of doing things using the properties file. You can also implement a RouteLocator bean and load the routes using some other mechanism.

Examples: - DiscoveryClientRouteLocator uses discovery to locate routes - SimpleRouteLocator uses the spring boot properties - https://jmnarloch.wordpress.com/2015/12/09/spring-cloud-zuul-cassandra-route-storage/