두 개의 백엔드 서버(8080, 8090)를 운영하면서, 요청 경로에 따라 적절한 서버로 요청을 분기(route) 시키는 방법
예시) 사용 중인 api.test.com
도메인에서
-
/service1
요청은 8090 포트로 전달 -
/service0
요청은 8080 포트로 전달
시스템 구성 요약
항목 |
내용 |
---|---|
도메인 |
|
기존 서버 |
8080 포트에서 |
새 서버 |
8090 포트에서 |
목적 |
경로에 따라 요청을 정확히 분기 |
server {
listen 443 ssl;
server_name api.test.com;
# 1. /service1 경로는 새 서버로 분기 (8090 포트)
location /service1 {
proxy_pass http://localhost:8090;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# 2. /service0 경로는 기존 서버로 분기 (8080 포트)
location /service0 {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}