Zuul is an L7 application gateway (Edge service) that provides capabilities for dynamic routing, load balancing (Ribbon) monitoring, resiliency, security, and more. So how does Zuul API Gateway fit into the picture, Zuul will provide the entry point into the application, it communicates with the Eureka Discovery Service to obtain what services are available, we then use Ribbon a load balancer built into Zuul to handle any loading balance to services that are running multiple instances, lastly Zuul can also use Spring Security to for example make sure that a JSON Web Token (JWT) is in the header before allowing to have access to service for instance (make sure the user is authenticated).
To setup a Zuul Gateway we create a project and pull in the below dependencies, we need the Eureka client (will need to communicate with Eureka) and Zuul, I have also got Spring Security and JWT.
We hadd the @EnableDiscoveryClient to allow us to connect to a Eureka Discover Service and then we add @EnableZuulProxy annotation which allows this application to be a Zuul API Gateway.
Next we update the properties file, we give the application a name and define the port that the service will run on, and add the URL of the Eureka Discovery Service.
There is no an order in which the application should start, when you look at the Eureka dashboard you should see something like the below screenshot
Now we can access a microservice via the Zuul Gateway using the URL http://localhost:8011/users-ws/users/status/check, we get a response back from the users-ws microservice.
As I mentioned in the Eureka setup if you configure a instance id in the Eureka client you can start multiple services as seen below, using the URL http://localhost:8011/users-ws/users/status/check will flip between the two services using the provided Ribbon load balancer.
![]() |
![]() |