Router: Zuul
In this lesson, we'll discuss routing with Zuul.
We'll cover the following
Introduction#
Zuul is the routing solution that is part of the Netflix stack.
Zuul is responsible for forwarding external calls to the correct microservice.
Zuul vs. reverse proxy#
The routing could also be provided by a Reverse Proxy.
A Reverse Proxy is a web server that is configured to forward incoming calls to other servers.
Zuul has a feature that a reverse proxy is lacking, dynamic filters:
- Depending on the properties of the HTTP request or external configurations, Zuul can forward certain calls to specific servers or execute logic for logging, for example.
- A developer can write custom code for the routing decision.
- The code can even be dynamically loaded as Groovy code at runtime.
In this way, Zuul ensures maximum flexibility.
- Zuul filters can also be used to implement central functionalities such as logging of all requests.
- A Zuul filter can implement the login, send information about the current user with the HTTP requests, and thereby implement authentication.
Zuul can take over typical functionalities of an API gateway (see Benefits & Challenges).
Zuul in the example#
In the example, Zuul is configured as a proxy and does not contain any special code. Zuul forwards access to a URL such as http://localhost:8080/order to the microservice called ORDER.
Forwarding works for all microservices registered in Eureka. Zuul reads the names of all microservices from Eureka and forwards the requests.
Of course, Zuul “reveals” which microservices the microservices system is made up of. However, Zuul can be reconfigured by routes and filters in a way where completely different microservices can be accessed under the same URL.
Zuul can also deliver static content. In the example, Zuul provides the web page from which the various microservices can be accessed.
Q U I Z
What is the difference between Zuul and a regular reverse proxy?
A)
Zuul can be used with Netflix whereas regular proxies cannot.
B)
They are the same thing.
C)
Zuul can do dynamic filtering whereas a reverse proxy does not.
In the next lesson, we’ll discuss load balancing with Ribbon.