-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix] forward-headers-strategy: native를 framework로 수정 #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @changuii, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 Swagger 환경에서 HTTPS 연결이 HTTP로 잘못 인식되는 문제를 해결하기 위해 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
📝 WalkthroughWalkthroughapplication.yml 파일의 서버 설정에서 Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
💭 추가 검토 고려사항이 변경은 매우 단순하지만, 프로덕션 환경에서는 미묘한 영향을 미칠 수 있는 부분입니다: 변경의 의미:
확인이 필요한 부분:
가능하면 staging 환경에서 프록시/로드 밸런서를 거친 요청들이 제대로 처리되는지 검증 후 병합하시면 좋겠습니다. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
안녕하세요. application.yml 파일에서 server.forward-headers-strategy 설정을 native에서 framework로 변경하신 내용을 확인했습니다. 리버스 프록시 환경에서 Swagger UI가 프로토콜을 잘못 인식하는 문제를 해결하기 위한 올바른 수정입니다. 이 변경으로 Spring 프레임워크 레벨에서 X-Forwarded-* 헤더를 처리하게 되어, 컨테이너에 독립적으로 동작하므로 더 안정적인 방법입니다. 좋은 수정입니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f6be359df2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| context-path: /api | ||
| shutdown: graceful | ||
| forward-headers-strategy: native | ||
| forward-headers-strategy: framework |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve X-Forwarded-For for logging
Switching server.forward-headers-strategy to framework registers Spring’s ForwardedHeaderFilter, which removes X-Forwarded-* headers from the request after adapting the remote address. Your LoggingFilter currently reads request.getHeader("X-Forwarded-For"), so once this change is active that header will be stripped and the logged ipAddress will become null for proxied requests. This is a regression for production logs when the app is behind a reverse proxy/load balancer; consider reading request.getRemoteAddr() post-filter or configuring the filter to keep the header if you still need it.
Useful? React with 👍 / 👎.
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/resources/application.yml (1)
1-6: 포워드 헤더 처리: 전략 선택 전에 프록시 신뢰 경계 확보 필수현재
framework전략은 Spring 레벨에서X-Forwarded-*헤더를 해석합니다. 이것 자체는 문제가 아니지만, 중요한 점은 포워드 헤더는 클라이언트가 위조할 수 있다는 것입니다. 이것은native든framework든 마찬가지입니다.따라서 가장 먼저 확인할 사항은:
- 에지 프록시(LB, API Gateway 등)에서 인터넷 facing 쪽의
Forwarded/X-Forwarded-*헤더를 모두 제거하고, 자신이 생성한 헤더만 앱으로 전달하는가?- 앱이 프록시를 거쳐야만 접근 가능한가 (직접 접근 차단)?
이 두 가지가 확보되면,
native와framework중 선택은 운영 선호도 차이입니다.옵션 A (
framework유지, Spring 레벨 일관성)
- 장점: 컨테이너 종류에 관계없이 동일한 동작; Spring 생태계와 통일된 처리
- 단점: 프록시 설정 의존성이 명확해야 함
옵션 B (
native변경, 컨테이너 네이티브 처리)
- 장점: Tomcat/Jetty 자체의 RemoteIpValve 같은 기능 활용; 필터 체인 단순화 가능
- 단점: 컨테이너별로 신뢰 프록시 설정을 별도로 관리해야 함
옵션 C (프로파일 분리)
prod:framework(프록시 뒤 확정)local/dev:none(직접 접근 환경)장점: 로컬에서 스푸핑 오작동 방지
단점: 프로파일 관리 복잡도핵심은 전략 선택이 아니라 프록시 설정입니다. 프록시 측 헤더 정제가 확보되었는지, 그리고 현재
framework선택의 배경(예: Swagger HTTPS 인식 문제)이 무엇인지 먼저 정리하면, 전략 선택은 자동으로 따라올 겁니다.
|
@coderabbitai 해당 속성 바꾸기 전과 후에 어떤식으로 동작하길래 HTTPS로 돌아가는거야? 이해할 수 없어. 알려줘. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🌐 Web query: 💡 Result:
References:
[1] https://docs.enterprise.spring.io/spring-boot/docs/3.2.18.2/reference/html/howto.html
문제 상황이 프로젝트는 아마도 리버스 프록시(로드 밸런서, API Gateway, Nginx 등) 뒤에서 실행되고 있을 것입니다. 일반적인 구조는 다음과 같습니다: 리버스 프록시가 HTTPS 요청을 받아서 백엔드로 HTTP로 전달하면서, 원래 프로토콜 정보를 헤더로 전달합니다:
native vs framework의 차이
|



#️⃣ 이슈 번호
#72
🛠️ 작업 내용
forward-headers-strategy: native를 framework로 수정
Summary by CodeRabbit
릴리스 노트
✏️ Tip: You can customize this high-level summary in your review settings.