0
votes

Lets consider the following situation.This example will only have urls containing localhost. I have a zuul proxy setup and lets say its running on port 8080. So

   Zuul proxy-
  localhost:8080

I have an eureka server setup running on port 81.

 Eureka server-
localhost:8081.

I have an application lets call it by name-example which is a REST web service. Its running on 3 different ports 82,83 and 84. All 3 instances are registered with eureka server. I have a filter setup in zuul for the uri /example.

So i expect consumers to call the zuul proxy at locahost:8080/example.

Now, in the application example for the request mapping /example, there is a controller setup.

So what i want to do is basically have the consumers call localhost:8080/example and route that request to localhost:8082/example, localhost:8083/example, localhost:8084/example . I know how to load balance using ribbon and eureka and have all the appropriate properties set to achieve that.

         zuul.routes.example.serviceid=example

         ribbon.eureka.enabled=true.

What i want to do is have ribbon look up the list of url(s) from eureka server and then call localhost:8082/example rather localhost:8082.

Is this possible?

Thank you in advance.

1
Have you tried zuul.stripPrefix=false?Ryan Baxter
My apologies Ryan it works. Went through the documentation then understood what that property is for. ThanksIndraneel Bende

1 Answers

1
votes

You need to specify the path & serviceId

zuul:
    routes:
        examplepath:
           path: /example/**
           serviceId: name-example
           stripPrefix: false

The serviceId is the name registered with Eureka. Hope you are specifying Eureka server details in you Zuul gateway.