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

경로 기반 마이크로서비스 라우팅

Nginx 위치 매칭을 사용해 단일 진입점 뒤의 서로 다른 백엔드 마이크로서비스로 URL 경로를 각각 라우팅합니다.

경로 기반 마이크로서비스 라우팅은(는) 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개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

One Door, Many Services

In a microservice system, clients should hit a single host while Nginx fans requests out to the right service based on the URL path.

This keeps clients simple and hides the internal topology.

The location Directive

Routing decisions live in location blocks. Each matches a path pattern and proxies to a specific upstream.

location /users/ {
    proxy_pass http://users-service/;
}
location /orders/ {
    proxy_pass http://orders-service/;
}

Defining Upstreams

Name each service in an upstream block so locations stay readable and you can scale instances later.

upstream users-service {
    server 10.0.0.1:8080;
}
upstream orders-service {
    server 10.0.0.2:8080;
}

Prefix vs Exact Match

A plain location /path/ is a prefix match. Use = for an exact match, which is faster and avoids accidental overlaps.

location = /health {
    return 200 "ok";
}

The Trailing Slash Rule

A trailing slash on proxy_pass changes path rewriting. With proxy_pass http://svc/; the matched prefix is stripped; without it the full path is forwarded.

location /users/ {
    proxy_pass http://users-service/;
}
# /users/42 -> upstream sees /42

Regex Locations

Prefix with ~ for case-sensitive regex matching, useful for routing by file type or dynamic segments.

location ~ ^/api/v[0-9]+/payments {
    proxy_pass http://payments-service;
}

Matching Priority

Nginx evaluates locations in a defined order: exact =, then literal prefixes, then regex in file order. Understanding this prevents surprising routes.

A Default Catch-All

Add a fallback location to serve a friendly response for unknown paths instead of leaking a default error.

location / {
    return 404 "Unknown service";
}

Shared Proxy Settings

Keep forwarding headers consistent across all services by including a shared snippet in each location.

location /users/ {
    include /etc/nginx/proxy_headers.conf;
    proxy_pass http://users-service/;
}

Adding a New Service

Onboarding a service is just a new upstream plus a new location, no client changes required, which is the whole point of a gateway.

upstream search-service { server 10.0.0.3:8080; }
location /search/ {
    proxy_pass http://search-service/;
}

Testing the Routes

After reloading, curl each path and confirm it reaches the intended service.

curl http://localhost/users/42
curl http://localhost/orders/7

Quick Check

With location /users/ { proxy_pass http://users-service/; }, what path does the upstream receive for a request to /users/42?

Recap

You built path-based routing to multiple services:

  • location blocks map paths to upstreams
  • Trailing slash on proxy_pass controls prefix stripping
  • Match types: exact =, prefix, and ~ regex
  • A catch-all handles unknown paths

One host now cleanly fronts an entire fleet of microservices.

자주 묻는 질문

“경로 기반 마이크로서비스 라우팅” 강의는 무료인가요?

네 — “경로 기반 마이크로서비스 라우팅” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의 전체를 잠금 해제할 수 있습니다. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 총 4개의 강의가 포함되어 있습니다.

“경로 기반 마이크로서비스 라우팅”에서 뭘 배우나요?

Nginx 위치 매칭을 사용해 단일 진입점 뒤의 서로 다른 백엔드 마이크로서비스로 URL 경로를 각각 라우팅합니다. 브라우저에서 직접 실행하는 실습 코드로 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번째 강의입니다.

“경로 기반 마이크로서비스 라우팅” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Nginx를 사용한 API 버전 관리
  2. 교차 출처 리소스 공유(CORS)
  3. Nginx를 사용한 요청률 제한 및 조절
  4. 경로 기반 마이크로서비스 라우팅
← API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)(으)로 돌아가기