We will use SPRING INITIALIZR (http://start.spring.io) to set up a new project for the Zuul API gateway. The following screenshot shows the GroupId, ArtifactId, and Dependencies to be selected:
The next step is to enable the Zuul proxy on the Spring Boot application. This is done by adding the @EnableZuulProxy annotation on the ZuulApiGatewayServerApplication class. The following snippet shows the details:
@EnableZuulProxy
@EnableDiscoveryClient
@SpringBootApplication
public class ZuulApiGatewayServerApplication {
We will run the Zuul proxy on port 8765. The following snippet shows the configuration that's needed in application.properties:
spring.application.name=zuul-api-gateway
server.port=8765
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
We are configuring the port for the Zuul proxy and connecting it to the Eureka name server as well.