docs: Update admin dashboard routing doc - link to standard deployment refactoring
This commit is contained in:
parent
04d470b126
commit
50e9ad884c
@ -23,102 +23,29 @@ robeing-gateway는 로빙 API 라우팅 전용으로 설계되어 `/admin` 경
|
|||||||
|
|
||||||
## 해결 방안 검토
|
## 해결 방안 검토
|
||||||
|
|
||||||
### 방안 1: nginx에서 직접 frontend-base로 프록시
|
**참고**: 이 문서는 초기 구현 방식을 기록한 것이며, 이후 표준 배포 방식으로 전환되었습니다. 최신 구현 방식은 다음 문서를 참고하세요:
|
||||||
```nginx
|
- **표준 배포 방식 전환**: `251117_admin_dashboard_standard_deployment_refactoring.md`
|
||||||
location /admin {
|
|
||||||
proxy_pass http://localhost:8000;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**문제점**:
|
### 초기 구현 (폐기됨)
|
||||||
- JWT 검증 불가 (인증 없이 접근 가능)
|
- Gateway가 frontend-base(localhost:8000)로 프록시하는 방식
|
||||||
- frontend-base가 51124 robeing-monitor 데이터 조회 시 인증/UUID 변환 로직 중복 필요
|
- FastAPI가 정적 HTML을 FileResponse로 서빙
|
||||||
|
|
||||||
### 방안 2: Gateway에 `/admin` 라우팅 추가 (채택)
|
### 최종 채택 방식
|
||||||
```python
|
- nginx가 정적 파일(`/home/admin/admin-dashboard/frontend/dist/`)을 직접 서빙
|
||||||
@app.api_route("/admin/{path:path}", methods=["GET", "POST", "PUT", "DELETE"])
|
- FastAPI는 API만 처리
|
||||||
async def admin_proxy(
|
- Gateway는 JWT 검증을 선택적으로 처리하여 HTML은 통과, API만 검증
|
||||||
path: str,
|
|
||||||
request: Request,
|
|
||||||
user_uuid: str = Depends(get_verified_user)
|
|
||||||
):
|
|
||||||
"""Admin dashboard - proxy to frontend-base (51123:8000)"""
|
|
||||||
frontend_base_url = "http://localhost:8000"
|
|
||||||
target_url = f"{frontend_base_url}/admin/{path}" if path else f"{frontend_base_url}/admin"
|
|
||||||
|
|
||||||
logger.info(f"Admin request from user {user_uuid} to {target_url}")
|
|
||||||
|
|
||||||
async with httpx.AsyncClient() as client:
|
|
||||||
response = await client.request(
|
|
||||||
method=request.method,
|
|
||||||
url=target_url,
|
|
||||||
headers=dict(request.headers),
|
|
||||||
content=await request.body()
|
|
||||||
)
|
|
||||||
|
|
||||||
return Response(
|
|
||||||
content=response.content,
|
|
||||||
status_code=response.status_code,
|
|
||||||
headers=dict(response.headers)
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
**장점**:
|
|
||||||
- JWT 검증 중앙화 유지
|
|
||||||
- frontend-base가 Gateway의 인증/UUID 변환 활용 가능
|
|
||||||
- 역할 분리 명확: Gateway(인증+라우팅), frontend-base(UI)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 구현 내역
|
## 구현 내역 (초기 구현 - 폐기됨)
|
||||||
|
|
||||||
### 1. robeing-gateway 코드 수정
|
이 문서는 초기 구현 방식을 기록한 것이며, 이후 표준 배포 방식으로 전환되었습니다.
|
||||||
|
|
||||||
**파일**: `/home/admin/robeing-gateway/app/main.py`
|
**초기 구현 내용**:
|
||||||
|
- Gateway에 `/admin` 라우팅 추가하여 frontend-base로 프록시
|
||||||
|
- FastAPI가 정적 HTML을 FileResponse로 서빙
|
||||||
|
|
||||||
**변경 사항**:
|
**최신 구현**: `251117_admin_dashboard_standard_deployment_refactoring.md` 참고
|
||||||
1. Import 추가 (line 7):
|
|
||||||
```python
|
|
||||||
from fastapi.responses import JSONResponse, Response
|
|
||||||
```
|
|
||||||
|
|
||||||
2. `/admin` 라우팅 추가 (line 392-417):
|
|
||||||
- JWT 검증: `get_verified_user()` Dependency 적용
|
|
||||||
- frontend-base(localhost:8000)로 프록시
|
|
||||||
- 모든 HTTP 메서드 지원 (GET, POST, PUT, DELETE)
|
|
||||||
|
|
||||||
### 2. Gateway 재시작
|
|
||||||
```bash
|
|
||||||
cd /home/admin/robeing-gateway
|
|
||||||
docker compose down && docker compose up -d --build
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3. 테스트 코드 작성
|
|
||||||
|
|
||||||
**파일**: `/home/admin/frontend-base/tests/test_admin_api.py`
|
|
||||||
|
|
||||||
**테스트 케이스**:
|
|
||||||
1. Gateway `/admin` - JWT 없음 → 401 예상
|
|
||||||
2. frontend-base `/health` → 200 OK
|
|
||||||
3. frontend-base `/admin` 직접 접근 → HTML 반환
|
|
||||||
|
|
||||||
**실행 결과**:
|
|
||||||
```
|
|
||||||
=== Test 1: Gateway /admin without JWT (예상: 401) ===
|
|
||||||
Status: 401
|
|
||||||
✅ JWT 검증 작동 확인
|
|
||||||
|
|
||||||
=== Test 2: frontend-base /health ===
|
|
||||||
Status: 200
|
|
||||||
✅ frontend-base 정상
|
|
||||||
|
|
||||||
=== Test 3: frontend-base /admin (직접 접근) ===
|
|
||||||
Status: 200
|
|
||||||
Content-Type: text/html; charset=utf-8
|
|
||||||
✅ Admin UI 정상
|
|
||||||
|
|
||||||
✅ 모든 테스트 통과
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -129,7 +56,7 @@ Content-Type: text/html; charset=utf-8
|
|||||||
사용자 → nginx → robeing-gateway → 404 (라우팅 없음)
|
사용자 → nginx → robeing-gateway → 404 (라우팅 없음)
|
||||||
```
|
```
|
||||||
|
|
||||||
### After (정상 동작)
|
### After (초기 구현 - 폐기됨)
|
||||||
```
|
```
|
||||||
사용자 → nginx (:80/443) → robeing-gateway (:8100)
|
사용자 → nginx (:80/443) → robeing-gateway (:8100)
|
||||||
↓ JWT 검증
|
↓ JWT 검증
|
||||||
@ -137,13 +64,7 @@ Content-Type: text/html; charset=utf-8
|
|||||||
→ frontend-base (:8000) → Admin UI 반환
|
→ frontend-base (:8000) → Admin UI 반환
|
||||||
```
|
```
|
||||||
|
|
||||||
### frontend-base가 robeing-monitor 데이터 조회 시
|
**최신 아키텍처**: `251117_admin_dashboard_standard_deployment_refactoring.md` 참고
|
||||||
```
|
|
||||||
사용자 → Gateway (:8100/admin)
|
|
||||||
→ frontend-base (:8000)
|
|
||||||
→ Gateway (:8100/api/stats) ← JWT 재사용
|
|
||||||
→ robeing-monitor (:9024, 51124 서버)
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -184,15 +105,18 @@ curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8100/admin
|
|||||||
- `/api/items` → robeing-monitor
|
- `/api/items` → robeing-monitor
|
||||||
- `/admin` → frontend-base (51123:8000)
|
- `/admin` → frontend-base (51123:8000)
|
||||||
|
|
||||||
### 역할 분리
|
### 역할 분리 (초기 설계 - 이후 변경됨)
|
||||||
- **robeing-gateway**: 인증 + 라우팅 (코드 없는 프록시)
|
- **robeing-gateway**: 인증 + 라우팅 (코드 없는 프록시)
|
||||||
- **frontend-base**: 관리자 UI + 시스템 메트릭 대시보드
|
- **frontend-base**: 관리자 UI + 시스템 메트릭 대시보드 (→ admin-dashboard로 변경)
|
||||||
- **robeing-monitor**: 로빙 통계, 아이템 관리 (51124)
|
- **robeing-monitor**: 로빙 통계, 아이템 관리 (51124)
|
||||||
|
|
||||||
|
**최신 구조**: `251117_admin_dashboard_standard_deployment_refactoring.md` 참고
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 관련 문서
|
## 관련 문서
|
||||||
|
|
||||||
|
- **표준 배포 방식 전환**: `251117_admin_dashboard_standard_deployment_refactoring.md` (최신)
|
||||||
- **Gateway 아키텍처**: `/home/admin/DOCS/book/300_architecture/gateway_proxy_patterns.md`
|
- **Gateway 아키텍처**: `/home/admin/DOCS/book/300_architecture/gateway_proxy_patterns.md`
|
||||||
- **전체 시스템 구조**: `/home/admin/DOCS/book/300_architecture/310_전체_시스템_구조_컨테이너와_마이크로서비스.md`
|
- **전체 시스템 구조**: `/home/admin/DOCS/book/300_architecture/310_전체_시스템_구조_컨테이너와_마이크로서비스.md`
|
||||||
- **Gateway 구현 히스토리**: `/home/admin/DOCS/journey/troubleshooting/250809_happybell80_robing-gateway구현.md`
|
- **Gateway 구현 히스토리**: `/home/admin/DOCS/journey/troubleshooting/250809_happybell80_robing-gateway구현.md`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user