Spring Cloud Gateway can create routes from services registered with Eureka, so clients can call one gateway instead of addressing service instances directly. To make that work, enable the discovery route locator for your Gateway release and include Spring Cloud LoadBalancer, which resolves the lb://service-name destination to an instance. By default, a request such as /orders/items is matched as a route for orders, and the gateway removes the service ID before forwarding.
How the gateway and Eureka work together
Eureka is the service registry: application instances register their service IDs and locations there. Spring Cloud Gateway uses Spring’s DiscoveryClient abstraction to obtain registered services and generate routes. A typical topology has a Eureka server, one or more registered backend services, and a Gateway Server application configured with a compatible Eureka client.
The gateway is the client-facing entry point. It can centralize routing and cross-cutting concerns such as security, monitoring, metrics, and resiliency; it does not replace the backend services or their registration with Eureka. Spring Cloud Gateway documents both Server and Proxy Exchange flavors, with WebFlux and Web MVC compatibility. Select the flavor that fits the application and use its matching dependencies and configuration.
Choose a compatible Gateway release first
The current Spring Cloud Gateway reference lists 5.0.3, 4.3.5, 4.2.7, and 4.1.9 as stable versions. Its overview describes Gateway 5.0.3 as built on Spring Framework 7, Spring Boot 4, and Project Reactor. That is documentation context, not a blanket recommendation to upgrade an existing application.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11#1 Best Overall
Dependency coordinates and configuration property names vary across Gateway generations. Choose a Gateway and Spring Cloud release train compatible with your Spring Boot version, then use that release’s documentation rather than copying properties from a different generation. For Gateway 5.0.3 Server WebFlux, the discovery locator settings use the spring.cloud.gateway.server.webflux.discovery.locator prefix; older documentation uses spring.cloud.gateway.discovery.locator.
What you need for Eureka-backed routes
- A Eureka server and registered services. Each backend must register under a service ID that the gateway can discover.
- A Gateway application with a Eureka-compatible DiscoveryClient. The discovery route locator works through the DiscoveryClient abstraction, which supports implementations including Netflix Eureka.
- Spring Cloud LoadBalancer. Discovery routes use
lb://service-name; addorg.springframework.cloud:spring-cloud-starter-loadbalancerso the gateway can select a discovered service instance. - Discovery routing enabled. The locator’s enabled flag is false by default in the current 5.0.3 configuration reference, so turn it on intentionally using the property namespace for your selected release and Gateway flavor.
The official references establish the locator behavior and required load-balancing dependency, but they do not define one universal build file or Eureka server configuration for every Spring Boot and Spring Cloud combination. Use the release train’s compatibility guidance for those project-specific choices.
Enable automatic routes
For Gateway 5.0.3 Server WebFlux, set the discovery locator’s enabled property to true under spring.cloud.gateway.server.webflux.discovery.locator. In an application configuration file, the relevant YAML shape is:
spring:
cloud:
gateway:
server:
webflux:
discovery:
locator:
enabled: true
This is the current 5.0.3 WebFlux property namespace. For another Gateway generation or the Web MVC variant, check the corresponding official configuration reference and use that variant’s property names.
With the default locator settings, Gateway builds a route for each included discovered service. Its destination is lb:// followed by the service ID. The current configuration reference also documents an option to lowercase service IDs, which can help when registry IDs are uppercase, and an include expression that defaults to true.
Understand the default route and path rewrite
- The client sends a request whose path begins with the service ID, for example
/orders/items. - The discovery-generated route matches the service ID path pattern, such as
/orders/**. - The gateway resolves the
lb://ordersdestination through Spring Cloud LoadBalancer and selects a discovered instance. - The default
RewritePathfilter removes the service ID prefix, so the backend receives/items.
This means the public gateway path and backend path are not necessarily identical. If the backend expects the service prefix to remain, the default rewrite behavior must be changed to match that contract. Conversely, if the backend serves routes without the prefix, keep the rewrite.
Rank #4
Be careful when customizing discovery locator filters: configuring a filter list replaces the complete default list. If you supply your own filters and omit RewritePath, the gateway no longer strips the service ID; a backend that expects the shortened path may respond with 404. Preserve or deliberately replace the rewrite behavior as part of the path contract.
Automatic discovery routes or explicit routes?
Discovery-generated routes are convenient when services are registered dynamically and the gateway should expose them according to locator rules. Explicit routes are preferable when only selected services should be reachable, or when each route needs a deliberately specified external path, filter chain, or destination behavior. These are design trade-offs, not claims about relative performance.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Whichever strategy you choose, decide whether the gateway should strip the service ID or preserve a prefix and ensure the backend routing agrees. Also verify service ID casing and inclusion rules against the registry and the selected release’s configuration.
Quick Recap
Official references
- DiscoveryClient Route Definition Locator
- Spring Cloud Gateway configuration properties
- Spring Cloud Gateway reference and version overview
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

