0Pricing
API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) · Lesson

The lb:// URI & Discovery Locator

Understand how Spring Cloud Gateway resolves the lb:// scheme through service discovery and how to auto-create routes from registered services.

From Hostnames to Service Names

Hardcoding http://10.0.0.5:8080 breaks when instances move. With service discovery the gateway can target a logical service name instead, and resolve real instances at runtime.

The lb Scheme

Prefix a route's uri with lb:// followed by the service id. The gateway hands the request to the load balancer, which picks a live instance.

routes:
  - id: orders
    uri: lb://order-service
    predicates:
      - Path=/orders/**

All lessons in this course

  1. Integrating with Eureka/Consul
  2. Dynamic Routing with Service Discovery
  3. Load Balancing with Spring Cloud LoadBalancer
  4. The lb:// URI & Discovery Locator
← Back to API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)