Routing request to same service registered as two different service-ID

1k views Asked by At

In my spring boot application, I m using Eureka server for the discovery service. In one of my Discovery client application I am using zuul proxy to route the requests to different services registered with the Discovery Server.

I have one resource application which is responsible for storing the data into the db. I have created two instances for this service registered as two different service with the discovery service. The api published for this service lets say is /resources Get,Post, etc

The client application sends request like /definitions and /locations for the two instances of this resource service.

Now my problem is I want to map this /definitions to service-id 1/resources and locations to /service-id2/resources.

I m not sure how to do this as when I send /defnitions from the client application it expects /definitions to be there in the resource application which is not the case.

I am trying something like this zuul: routes: locations: path: /locations/** rewrite: /resources/** serviceId: location_service stripPrefix: false definitions: path: /definitions/** rewrite: /resources/** serviceId: definition_service stripPrefix: false

1

There are 1 answers

0
hi_my_name_is On

you are using stripPrefix: false in both cases. It means zuul will not cut it from request url and pass to your proxied service. Try to play with that.

At least in spring-cloud org.springframework.cloud.netflix.zuul.filters.ZuulProperties file there is no 'rewrite' property, are you sure its correct?