Use case for @EnableZuulServer

2.4k views Asked by At

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?

2

There are 2 answers

0
dustin.schultz On

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.

0
Bhushan On

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.