You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
프록시(Proxy)는 클라이언트와 서버 사이에서 중계 역할을 하는 서버 또는 소프트웨어를 의미합니다. 쉽게 말해, 사용자가 직접 서버와 통신하지 않고, 프록시 서버를 거쳐서 데이터를 주고받도록 하는 것입니다.
🔹 프록시의 주요 역할
1. 보안 강화
사용자의 실제 IP 주소를 숨겨 익명성을 제공
방화벽 기능을 수행하여 외부의 공격을 차단
2. 캐싱(Caching)으로 속도 향상
자주 요청되는 데이터를 미리 저장해 불필요한 서버 요청을 줄이고 성능을 향상
3. 웹 필터링
특정 사이트 접근을 제한하거나, 유해 콘텐츠를 차단
4. 부하 분산(Load Balancing)
여러 서버로 트래픽을 분산해 서버 과부하를 방지
5. 우회 접속
차단된 웹사이트나 네트워크에 접근할 수 있도록 우회 연결 지원
🔹 프록시의 종류
🔹 프록시를 사용하는 대표적인 예시
회사에서 직원들이 특정 사이트(예: SNS, 유튜브)에 접속하지 못하도록 차단
CDN(Content Delivery Network)에서 리버스 프록시를 활용하여 부하를 분산
사용자들이 프록시 서버를 통해 차단된 사이트에 접근
프록시는 보안, 성능, 우회 접속 등 다양한 목적으로 활용
1️⃣ 포워드 프록시 (Forward Proxy)
사용자가 요청을 보내면, 프록시 서버가 대신 외부 API 서버에 요청을 보내고 결과를 반환하는 방식이다.
🔹 Spring Boot + RestTemplate을 활용한 포워드 프록시 구현
🔹 실행 후 사용 예시
http://localhost:8080/proxy/posts 요청 시
→ 실제로는 https://jsonplaceholder.typicode.com/posts 데이터를 받아 반환
클라이언트는 실제 API 서버를 모르고, 프록시를 통해 요청을 보냄
2️⃣ 리버스 프록시 (Reverse Proxy)
클라이언트의 요청을 받아 내부 서버로 전달하는 방식이다. 보안 강화 및 부하 분산(Load Balancing) 등에 사용된다.
🔹 Spring Boot + Spring Cloud Gateway를 활용한 리버스 프록시 구현
먼저, Spring Cloud Gateway 라이브러리를 pom.xml에 추가하자.
🔹 실행 후 사용 예시
클라이언트가 http://localhost:8080/api/test에 요청을 보내면
→ 실제 요청이 http://localhost:5000/test로 전달됨
외부에서 직접 내부 서버(5000번 포트)에 접근할 수 없고, 프록시를 통해 접근 가능
Beta Was this translation helpful? Give feedback.
All reactions