Skip to content

[fix] Swagger 요청이 https가 아닌 http로 전송되는 문제 - #63

Merged
theminjunchoi merged 1 commit into
devfrom
fix/62-swagger-https
Jul 29, 2026
Merged

[fix] Swagger 요청이 https가 아닌 http로 전송되는 문제#63
theminjunchoi merged 1 commit into
devfrom
fix/62-swagger-https

Conversation

@theminjunchoi

Copy link
Copy Markdown
Collaborator

🔗 연관 이슈

📌 문제

Swagger UI에서 API 실행 시 요청이 https://가 아니라 http://dev-api.gamss.kr/... 로 전송됨(Request URL·curl 모두). HTTPS 엣지(nginx) 뒤인데 문서가 http로 URL을 생성.

🔍 원인

  • nginx는 이미 X-Forwarded-Proto $scheme(443이면 https)를 앱에 전달 중.
  • 그러나 앱(Spring Boot)에 server.forward-headers-strategy 미설정X-Forwarded-Proto를 무시 → springdoc이 요청을 http로 인식해 OpenAPI servers URL을 http://로 생성.
  • SwaggerConfig는 server URL을 명시하지 않아 요청 스킴을 그대로 사용.

🔧 변경

  • application.ymlserver.forward-headers-strategy: framework 추가.
  • Spring ForwardedHeaderFilterX-Forwarded-Proto/Host를 반영 → 문서·Try it out URL이 https로 생성.
  • 앱 포트는 127.0.0.1:8080에만 바인딩돼 nginx만 접근 가능 → 헤더 신뢰 안전(외부 위조 주입 불가).
  • 내부 nginx → appproxy_pass http://...(같은 서버 평문 연결)는 변경하지 않음(정상 동작).

✅ 검증 (런타임)

요청 결과
프록시 헤더 없음(로컬 직접) http://localhost:8080 (정상)
X-Forwarded-Proto: https (nginx처럼) https://dev-api.gamss.kr

🌐 API · DB 영향

  • API 변경: 없음(설정만). DB: 없음.

nginx가 넘기는 X-Forwarded-Proto/Host 를 Spring이 반영하도록
server.forward-headers-strategy=framework 를 추가한다. 이전엔 앱이 프록시 헤더를
무시해 springdoc이 http로 URL을 생성했다. 앱 포트는 127.0.0.1 바인딩이라 nginx만
접근하므로 헤더 신뢰가 안전하다.
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@theminjunchoi, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: eab47c53-141c-4d6a-a2dd-014b104ae9a9

📥 Commits

Reviewing files that changed from the base of the PR and between 703ce53 and 5b75d25.

📒 Files selected for processing (1)
  • src/main/resources/application.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/62-swagger-https

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.

@github-actions

Copy link
Copy Markdown

Test Results

291 tests  ±0   291 ✅ ±0   1m 16s ⏱️ -5s
 46 suites ±0     0 💤 ±0 
 46 files   ±0     0 ❌ ±0 

Results for commit 5b75d25. ± Comparison against base commit 703ce53.

@github-actions

Copy link
Copy Markdown

Test Coverage

Overall Project 74.46% 🍏

There is no coverage information present for the Files changed

@theminjunchoi
theminjunchoi requested a review from kite707 July 28, 2026 16:34

@kite707 kite707 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverse proxy 환경에서 Forwarded 헤더 처리를 통해 Swagger URL이 HTTPS를 사용하도록 구성된 점 확인했습니다!

고생하셨습니다!

@theminjunchoi
theminjunchoi merged commit 61e8f93 into dev Jul 29, 2026
4 checks passed
@theminjunchoi
theminjunchoi deleted the fix/62-swagger-https branch July 29, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] Swagger 요청이 https가 아닌 http로 전송되는 문제

2 participants