Skip to content

nginx 프론트의 Host 헤더 누락으로 인한 Tomcat 400 수정 - #28

Merged
m-a-king merged 1 commit into
mainfrom
fix/nginx-host-header
Aug 10, 2026
Merged

nginx 프론트의 Host 헤더 누락으로 인한 Tomcat 400 수정#28
m-a-king merged 1 commit into
mainfrom
fix/nginx-host-header

Conversation

@m-a-king

@m-a-king m-a-king commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Situation

  • 배포를 main push 자동 + blue-green 무중단 전환으로 개편 #27 머지로 실행된 이행 1회차 배포가 전환 후 최종 헬스체크(:8090 경유)에서 400 으로 실패했다. 원복 로직이 새 슬롯을 정리했지만 이행 1회차라 레거시 컨테이너는 이미 제거된 뒤였고, 약 10분간 extractor 가 전 환경에서 다운됐다 (nginx 502).
  • 원인 실측: proxy_set_header Host 가 없으면 nginx 는 upstream 이름을 Host 헤더로 넘긴다. upstream 이름 piki_extractor 의 언더스코어를 Tomcat 이 RFC 위반 도메인으로 보고 400 을 뱉었다. 같은 슬롯에 Host 정상 = 200, Host: piki_extractor = 400 으로 확정했다. core 의 conf 는 upstream 이름이 team3 라 언더스코어가 없어 우연히 무사했던 함정이다.

Task

  • 프론트가 어떤 upstream 이름이든 Host 를 원 요청 값으로 넘기게 해 400 재발을 막는다.
  • 박스에 이미 적용한 핫픽스와 repo 정본을 일치시킨다 - 어긋난 채로 다음 배포가 conf 를 덮으면 같은 장애가 재발한다.

Action

  • infra/nginx/extractor.conf 의 proxy location 에 proxy_set_header Host $host; 한 줄을 추가하고, 함정의 실측 근거를 주석으로 남겼다.
  • 장애 복구는 이 PR 과 별개로 완료된 상태다: 새 이미지로 blue 슬롯 재기동 + 박스 conf 직접 수정 + reload 후, 실소비 경로(:8090)로 톡딜 상품 추출 E2E 200 을 확인했다.

Result

  • 검증: 수정 conf docker nginx -t 통과. 박스에는 같은 내용이 이미 적용돼 프론트 200 서빙 중이다.
  • 이 PR 의 머지가 트리거하는 배포는 레거시가 없는 첫 정상 전환(blue → green reload)이라, 무중단 슬롯 전환의 실측 검증을 겸한다.
  • 남는 교훈: 최종 헬스체크가 이행 1회차에서 실패하면 되돌아갈 대상이 없다는 한계는 이행이 끝난 지금 소멸했다. 전환 실패 시 원복(이전 슬롯 유지)은 배포를 main push 자동 + blue-green 무중단 전환으로 개편 #27 의 로직이 그대로 담당한다.

연관 이슈

Summary by CodeRabbit

  • 버그 수정
    • 백엔드 요청 시 원래 접속한 호스트 정보가 올바르게 전달되도록 개선했습니다.
    • 프록시 환경에서 호스트 기반 처리의 안정성이 향상되었습니다.

- 이행 배포 실측: proxy_set_header Host 부재 시 nginx 가 upstream 이름(piki_extractor)을 Host 로 전달하고, Tomcat 이 언더스코어 도메인을 400 으로 거절해 프론트 전체가 400 이 됐다 (원복 로직이 새 슬롯을 정리한 상태에서 레거시는 이미 제거된 이행 1회차라 약 10분 다운타임)
- 박스에는 동일 수정을 핫픽스로 이미 적용해 복구 완료 - 이 커밋은 repo 정본을 박스와 일치시켜 다음 배포가 conf 를 덮어도 재발하지 않게 한다
- 검증: 같은 슬롯에 Host 정상=200 / Host piki_extractor=400 실측으로 원인 확정, 수정 conf 는 docker nginx -t 통과
@m-a-king m-a-king added the fix 외부 가시적 결함 수정 label Aug 10, 2026
@m-a-king m-a-king self-assigned this Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b29179eb-b497-49f6-90a8-b279e948e912

📥 Commits

Reviewing files that changed from the base of the PR and between 59104db and 3b4469b.

📒 Files selected for processing (1)
  • infra/nginx/extractor.conf

📝 Walkthrough

Walkthrough

Nginx 루트 프록시 경로가 upstream 이름 대신 클라이언트 요청의 $host 값을 백엔드의 Host 헤더로 전달합니다.

Changes

Nginx 프록시 헤더 변경

Layer / File(s) Summary
원래 요청 호스트 전달
infra/nginx/extractor.conf
루트 프록시 경로에 proxy_set_header Host $host; 설정을 추가했습니다.

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 nginx의 Host 헤더 누락으로 발생한 Tomcat 400 오류 수정이라는 주요 변경 사항을 정확히 요약합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@m-a-king
m-a-king merged commit 5f94b58 into main Aug 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix 외부 가시적 결함 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant