
이번 글을 통해 배워 갈 내용
- Oauth 로그인 시에 https 대신 http 가 떠서 소셜로그인이 안 되는 경우 해결방법입니다
구글 OAuth 로그인 시에
https 로 redirect를 설정했는데 http로 전송이 돼서 아래와 같은 오류 메시지가 뜨는 경우


일단 application.properties 파일에 아래와 같이 추가해 줍니다
server.forward-headers-strategy=native
그다음 nginx를 사용하신다면 아래와 같이 프락시 설정을 해줍니다
proxy_set_header Host $http_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;
간단 설명
forward-headers-strategy:native
forwared header를 다루는 방법을 설정하며
proxy 서버(예 Nginx)에서 설정한 header를 다룹니다
이번 예제에서는 스프링 부트 앱 앞에 있는 nginx에서 다루는 reverse 프락시를 다루었습니다
서버에서 기본으로 제공하는 native 방법을 채택합니다
proxy_set_header Host $http_host;
도메인명 같은 host header를 설정합니다
이를 통해 nginx가 원본 host header를 스프링에 보내는 것을 보장합니다
proxy_set_header X-Real-IP $remote_addr;
remote_addr를 판별하는데 유용하게 사용됩니다
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
거쳐서 온 프록시의 IP 주소들을 보여줍니다
proxy_set_header X-Forwarded-Proto $scheme;
원본 request 가 http인지 https 인지 판별해 줍니다
참조 및 인용
https://stackoverflow.com/questions/33812471
Spring OAuth redirect_uri not using https
I have a Spring Boot 1.3.0 application with Spring Security OAuth included as a sort of SSO integration. The problem is that the application is running in a non-SSL environment with a non-standard...
stackoverflow.com
블로그 추천 포스트
https://codemasterkimc.tistory.com/50
300년차 개발자의 좋은 코드 5계명 (Clean Code)
이번 글을 통해 배워갈 내용 좋은 코드(Clean Code)를 작성하기 위해 개발자로서 생각해볼 5가지 요소를 알아보겠습니다. 개요 좋은 코드란 무엇일까요? 저는 자원이 한정적인 컴퓨터 세상에서 좋
codemasterkimc.tistory.com
오늘도 즐거운 코딩 하시길 바랍니다 ~ :)
'Spring' 카테고리의 다른 글
| 도커 네트워크에서 프로메테우스, 스프링 부트 및 스프링 시큐리티 마스터하기: 종합 가이드 (0) | 2024.01.10 |
|---|---|
| 프로메테우스, 그라파나, 집킨으로 스프링 부트 모니터링 하는 한가지 방법 (0) | 2023.11.24 |
| Spring JPA entity in Kotlin Class (0) | 2023.08.21 |
| Spring Social Login Spring Boot 3.1.1 버전으로 업하면서 생긴 버그 픽스 (0) | 2023.07.18 |
| 스프링 부트 3.3 업데이트 이후 NullPointerException UnsatisfiedDependencyException 이 발생한다면 (1) | 2023.02.26 |