diff --git a/troubleshooting/250809_happybell80_robing-gateway구현.md b/troubleshooting/250809_happybell80_robing-gateway구현.md index 50e28f6..63a9512 100644 --- a/troubleshooting/250809_happybell80_robing-gateway구현.md +++ b/troubleshooting/250809_happybell80_robing-gateway구현.md @@ -166,15 +166,72 @@ INSERT INTO workspace_members ( - JWT 토큰 검증 - 세션 관리 +## 오후 1시 30분 - Frontend 통합 및 프로덕션 배포 + +### Frontend 연동 작업 + +**nginx 설정 추가**: +```nginx +# HTTP와 HTTPS 모두에 추가 +location ^~ /gateway/ { + proxy_pass http://localhost:8100/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; +} +``` + +**Frontend 수정**: +```javascript +// robing-api.ts 변경사항 +// 1. 엔드포인트: /api/message → /api/chat +// 2. X-User-Id 헤더 추가 +// 3. 요청 body: text → message 필드 + +headers: { + 'Content-Type': 'application/json', + 'X-User-Id': userId +}, +body: JSON.stringify({ + message: text, // Gateway가 text로 변환 + user_id: userId +}) +``` + +### 통합 테스트 결과 + +**시스템 상태 (오후 1:44 기준)**: +- Gateway 컨테이너: 2시간째 안정 운영 (healthy) +- nginx 프록시: 정상 작동 +- Frontend: 최신 빌드 배포 완료 (13:39) +- rb10508_micro: 정상 응답 + +**통신 경로 검증**: +``` +https://ro-being.com/gateway/api/chat +→ nginx (/gateway/) +→ Gateway (localhost:8100) +→ rb10508_micro (192.168.219.52:10508) +→ 응답: "안녕하세요. 로빙입니다. 무엇을 도와드릴까요?" +``` + +**운영 지표**: +- Health Check: ✅ (cache_size: 1, DB 연결 정상) +- 캐시 TTL: 30분 (사용자 매핑 유지) +- 기본 로빙: rb10508_micro (워크스페이스 미할당 사용자용) + ## 교훈 1. **기존 스키마 활용**: 새 테이블 생성보다 기존 구조 재사용이 효율적 2. **Docker 네트워킹**: 컨테이너에서 호스트 DB 접근 시 host.docker.internal 사용 3. **API 명세 확인**: 프록시 대상 서비스의 정확한 엔드포인트와 요청 형식 사전 확인 필수 4. **단계적 구현**: Phase 1에서 기본 기능 구현 후 점진적 기능 추가 +5. **nginx 프록시 설정**: proxy_pass 끝에 `/` 필수, HTTP/HTTPS 모두 설정 +6. **환경변수 관리**: 서버 .env와 프론트 .env 분리 관리 (VITE_ prefix) ## 참고 자료 - 서비스 재구조화 계획: `/DOCS/ideas/250807_서비스_재구조화_계획.md` - Gateway 저장소: `https://git.ro-being.com/ivada_Ro-being/robeing-gateway` -- 포트 정보: 8100 (테스트) → 8000 (프로덕션, frontend-base 대체 시) \ No newline at end of file +- 포트 정보: 8100 (현재) → 8000 (프로덕션, frontend-base 대체 시) \ No newline at end of file