Search code examples
javamicroservicesnetflix-eurekanetflix-zuul

Zuul Gateway Server is not showing any routes


I am have created an Gateway Server and registered it with Eureka. Below it is the bootstrap class:

@SpringBootApplication
@EnableZuulServer
@EnableDiscoveryClient
public class GatewayServerApplication {
   ...
}

I have integrated Zuul Gateway Server with Eureka Server. Everything is going OK. Eureka is starting successfully and the also the Gateway Server is starting successfully. Nevertheless, I am having trouble accessing the routes. Below is the link that i am trying to access:

https://localhost:5555/actuator/routes

Please, help me with this issue.

Thanks in advance.

P.S my configuration information for gateway server in application.properties file:

#Application
server.port=5555

#Eureka
cloud.config.enabled=true
eureka.instance.preferIpAddress=true
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka-server/


#Actuator
management.endpoints.web.exposure.include=*
management.security.enabled=false

Solution

  • Change the @EnableZuulServer to @EnableZuulProxy, like below:

    @SpringBootApplication
    @EnableZuulProxy
    @EnableDiscoveryClient
    public class GatewayServerApplication {
       ...
    }
    

    You have two option for creating Zuul Gateway Server:

    • The first one is to use @EnableZuulServer annotation. This annotation creates a Zuul Server but doesn't offer the Zuul pre-built routing capabilities. You use this annotation when you want to build your own routing service.

    • The second option is to use the @EnableZuulProxy annotation. This annotation creates Zuul Server, loads the Zuul Reverse Proxy Filters, and automatically uses Eureka Server to lookup services by their service IDs and then use Netflix Ribbon to do client-side load balancing of requests from within Zuul.

    I think in your case is more suited to use @EnableZuulProxy annotation because you don't want to build your own custom service.