lb:// URI 및 검색 로케이터
Spring Cloud Gateway가 서비스 검색을 통해 lb:// 스킴을 확인하는 방식과 등록된 서비스에서 경로를 자동으로 생성하는 방법을 이해합니다.
lb:// URI 및 검색 로케이터은(는) CoddyKit의 무료 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
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/**How lb Is Resolved
At request time the gateway asks the discovery client (Eureka, Consul, etc.) for instances of order-service, then Spring Cloud LoadBalancer selects one. The lb:// host is replaced by a concrete address.
Required Dependencies
You need a discovery client and the load balancer on the classpath. With Eureka:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>The Discovery Locator
Instead of writing a route per service, enable the DiscoveryClient route locator. It auto-generates a route for every registered service.
spring:
cloud:
gateway:
discovery:
locator:
enabled: trueAuto-Generated Paths
By default each service is reachable at /SERVICE-ID/**. A service named order-service answers at /order-service/**, forwarded as lb://order-service.
# request /order-service/orders/42
# -> lb://order-service /orders/42Lowercasing Service IDs
Eureka often registers service ids in uppercase. Enable lowercasing so paths stay clean and predictable.
spring:
cloud:
gateway:
discovery:
locator:
lower-case-service-id: trueMixing Manual and Auto Routes
You can keep the discovery locator on for convenience while still defining explicit routes for services that need custom predicates or filters.
routes:
- id: orders-custom
uri: lb://order-service
predicates:
- Path=/api/orders/**
filters:
- StripPrefix=1When Auto Routes Are Risky
The locator exposes every service automatically, including internal ones. In production, many teams disable it and define routes explicitly for tighter control.
Health-Aware Selection
Because resolution happens per request, instances that deregister or fail health checks are dropped from the pool. New instances appear automatically as they register.
Verifying Resolution
Enable debug logging for the load balancer to see which instance each request was routed to.
logging:
level:
org.springframework.cloud.loadbalancer: DEBUGQuick Check
What does the lb:// prefix on a route's URI tell the gateway to do?
Recap
You connected the gateway to service discovery:
lb://service-idresolves instances dynamically- A discovery client and load balancer must be present
- The discovery locator auto-creates routes at
/service-id/** - Disable or scope it in production for safety
This is the backbone of dynamic, resilient routing.
AI 튜터와 함께 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)을(를) 배우세요 — 무료
브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.
- 코스
- 12
- 레슨
- 48
자주 묻는 질문
“lb:// URI 및 검색 로케이터” 강의는 무료인가요?
네 — “lb:// URI 및 검색 로케이터” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의 전체를 잠금 해제할 수 있습니다. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 총 4개의 강의가 포함되어 있습니다.
“lb:// URI 및 검색 로케이터”에서 뭘 배우나요?
Spring Cloud Gateway가 서비스 검색을 통해 lb:// 스킴을 확인하는 방식과 등록된 서비스에서 경로를 자동으로 생성하는 방법을 이해합니다. 브라우저에서 직접 실행하는 실습 코드로 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“lb:// URI 및 검색 로케이터” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- Eureka 및 Consul 연동
- 서비스 검색을 사용한 동적 라우팅
- Spring Cloud LoadBalancer를 사용한 부하 분산
- lb:// URI 및 검색 로케이터