Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use case for @EnableZuulServer

I am wondering what use case would be served by @EnableZuulServer?

In my case I want to use the ZuulFilter framework for micro-services, and also the spring handlerMappings on Controllers to be called after passing through the Zuul Filter framework. Do not want proxy forwarding.

Is that possible and how? Can we use @EnableZuulServer mode for this scenario? I didn't find much documentation to be able to understand how @EnableZuulServer would work.

Can someone explain and help?

like image 406
AnandW Avatar asked Mar 10 '23 06:03

AnandW


2 Answers

From the Spring Cloud Netflix documentation:

Spring Cloud Netflix installs a number of filters based on which annotation was used to enable Zuul. @EnableZuulProxy is a superset of @EnableZuulServer. In other words, @EnableZuulProxy contains all filters installed by @EnableZuulServer. The additional filters in the "proxy" enable routing functionality. If you want a "blank" Zuul, you should use @EnableZuulServer.

Based on that, the answer to your question is: yes.

You can add the @EnableZuulServer annotation and you will not get proxy forwarding but you will still be able to use the ZuulFilter framework.

That said, if you're just looking to filter requests and responses, you can use a standard Servlet Filter along with a FilterRegistrationBean(relevant javadoc)

As far as a use case goes, you'd use @EnableZuulServer when you need more customized behavior than what is available with @EnableZuulProxy.

So, for instance, maybe for debug purposes you want to be able to support a request header that proxies your request to a specified host when the request originates from within a specific IP range.

like image 128
dustin.schultz Avatar answered Apr 05 '23 13:04

dustin.schultz


From the Spring Cloud Netflix documentation:

In this case the routes into the Zuul server are still specified by configuring "zuul.routes.*", but there is no service discovery and no proxying, so the "serviceId" and "url" settings are ignored.

like image 36
Bhushan Avatar answered Apr 05 '23 14:04

Bhushan