0
votes

In a spring-cloud-netflix setup (everything uses feign,ribbon,eureka,zuul), is there any simple/elegant/out-of-the-box way (i.e. discovery based on serviceId vs URL) for CompositeAB to communicate to ServiceA and ServiceB through Zuul? In all of the examples I've seen, CompositeAB discovers and calls ServiceA directly vs. via the Zuul route for ServiceA.

Put another way, if ServiceA registers itself in Eureka as service-a, is the automatically created Zuul proxy for service-a exposed in Eureka in any discoverable way?

For real world context, this relates to network topology and firewalls (there's no direct route between CompositeAB and ServiceA - everything needs to go through the gateway). Using URLs in CompositeAB isn't awful, but seems to defeat the purpose of having the registry present (ideally, Zuul would register the proxy for service-a as something like "zuul-service-a" in the registry). That said, i do get how this particular use case doesn't really fit Zuul's purpose as an edge gateway.

Finally, i think i know how to get my desired effect through code - just wanted to check that i wasn't reinventing any wheels first.

1

1 Answers

0
votes

Make sure that your Zuul proxy is registering with Eureka and fetching the registry. Any service that registers with eureka will get a route.

You don't have to allow every service that registers with eureka to be accessible via the proxy either.

A sample application.yml for your Zuul proxy that only allows service-a and service-b:

eureka:
  client:
    fetchRegistry: true

zuul:
  add-proxy-headers: true
  ignored-services: "*"
  routes:
    service-a:
      serviceId: service-a
    service-b:
      serviceId: service-b