본문 바로가기
WEB/APACHE

19. reverse proxy 설정(=gateway server)

by coldplayer83 2025. 12. 3.
728x90
반응형

https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html

 

Reverse Proxy Guide - Apache HTTP Server Version 2.4

Reverse Proxy Guide In addition to being a "basic" web server, and providing static and dynamic content to end-users, Apache httpd (as well as most other web servers) can also act as a reverse proxy server, also-known-as a "gateway" server. In such scenari

httpd.apache.org

 

모듈 로딩

LoadModule proxy_module "${PRODUCT_HOME}/modules/mod_proxy.so"
LoadModule proxy_http_module "${PRODUCT_HOME}/modules/mod_proxy_http.so"

 

reverse proxy 설정)

 

/로 들어오는 요청을 단일 백엔드 서버로 전달

ProxyPass "/"  "http://www.example.com/"

또는

ProxyPass "/"  "http://www.example.com/"
ProxyPassReverse "/"  "http://www.example.com/"

 

특정 uri로 들어오는 요청을 proxy 서버에 전달

ProxyPass "/images"  "http://www.example.com/"
ProxyPassReverse "/images"  "http://www.example.com/"

 

클러스터링 된 백엔드로 전달

<Proxy balancer://myset>
    BalancerMember http://www2.example.com:8080
    BalancerMember http://www3.example.com:8080
    ProxySet lbmethod=bytraffic
</Proxy>

ProxyPass "/images/"  "balancer://myset/"
ProxyPassReverse "/images/"  "balancer://myset/"

 


 

프록시 설정 값

 

ProxyPass : 요청을 backend server와 매핑. 외부에서 요청한 서버 url을 내부 서버 url로 변경

ProxyPassReverse : 백엔드에서 생성된 헤더가 백엔드가 아닌 리버스 프록시를 가리키도록 수정

proxyRequests : on | off(기본값)

on일 경우 Forward Proxy로 동작. off일 경우 Reverse Proxy로 동작

proxyPreserveHost : on | off(기본값)

클라이언트가 보낸 Host 헤더를 그대로 백엔드 프록시 요청에 사용

on으로 설정시 HTTP 요청 헤더의 Host: 부분에 지정된 호스트 이름 대신 들어오는 요청의 줄을 프록시된 호스트로 전달

off로 설정시 Apache가 백엔드에 전달할 때 Host 헤더를 백엔드 주소로 바꿔 버림
ex) test.co.kr → 10.20.30.40

728x90
반응형

'WEB > APACHE' 카테고리의 다른 글

21. 디렉토리 리스팅(directory listing)  (0) 2025.12.15
20. forward proxy 설정  (0) 2025.12.03
18. proxy  (0) 2025.12.03
curl로 https 인증서 접속 확인하기  (0) 2025.10.01
[템플릿용] 아파치 스크립트  (0) 2025.09.19