Moving from Spring Cloud Netflix Zuul to Spring Cloud Gateway

I’ve been using Netflix Zuul for many years as a proxy for APIs. Some weeks ago I tried to bootstrap a new project and add the zuul starter via spring initializr and couldn’t find it anymore. After some research it seems that Spring Cloud has moved over to Cloud Gateway and discontinued Netflix Zuul. Maybe this was just a rebranding of the Spring team but tbh I don’t care and want to follow the Spring Cloud team with that.

You can add Cloud Gateway to your app with a simple starter:


Please make sure to use the appropriate version. It is included in the spring cloud starter parent which you can easily import into your project.


With the starter in place you only need a starter class annotated with SpringBootApplication to start using it. Here a simple example:

  port: 8090

        - id: header_route
          uri: http://localhost:8080
            - Header=X-Tenant, mbodev
            - AddRequestHeader=Authorization, Basic dXNlcm5hbWU6cGFzc3dvcmQ=
        - name: CircuitBreaker
            name: fallbackCircuitBreaker
            fallbackUri: forward:/fallback
        - PreserveHostHeader
        - name: RequestSize
            maxSize: 5MB
        - SecureHeaders
        - DedupeResponseHeader=Vary Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_UNIQUE
              - "*"
              - GET
              - POST
              - PUT
              - DELETE
              - HEAD
              - OPTIONS
              - Accept
              - Content-Type
              - Origin
              - X-Tenant
            allowCredentials: false
        add-to-simple-url-handler-mapping: true

This config would take all requests with a header “X-Tenant: mbodev” and add an authorization header when forwarding the request to the given uri (http://localhost:8080). Further it adds some default filters like a CircuitBreaker, SecureHeaders, … Documentation of all these filters can be found in the official documentation of Cloud Gateway. If you copy these settings please be notified that CORS is set to allowedOrigins: “*”!

Also adding/writing custom filters is quite easy. So in general I appreciate Spring Cloud’s decision to move further with Cloud Gateway.

The example also includes a fallback in the circuit breaker config. Here the Kotlin sample I wrote for this:

import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.server.reactive.ServerHttpResponse
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Mono

class FallbackController {

    @GetMapping(path = ["/fallback"], produces = [MediaType.APPLICATION_JSON_VALUE])
    fun fallback(response: ServerHttpResponse): Mono<FallbackResponse> {
        response.statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
        return Mono.just(
                title = response.statusCode!!.name,
                message = "the requested url isn't available at the moment",
                code = response.statusCode!!.value(),


Here the used response model:

data class FallbackResponse(
    val title: String,
    val message: String,
    val code: Int,