리눅스

Total 331
Today 0
profile_image
윤진한
06-05-26 16:04 0개 23회
일반문서
Running a Reverse Proxy with Apache 주어담기.(1)
http://www.apacheweek.com/features/reverseproxies  참조 번역

 

워낙에들 안봐서 ㅋㅋ...., 우선 위사이트에서 보충설명 좀 넣거나, 필요없는 구문은 대강 건너뛰면서 번역해 올려봅니다. 도움이 되길~^^;;

 

Web Proxies

 

Proxy server는 크게 웹에 대한 사용자의 gateway이다. 사용자가 브라우저 세팅에서 proxy를 설정하면 모든 HTTP request는 proxy를 통해 route된다.

일반적으로 proxy는 다음과 같은 역할에 사용된다.

 

  *  caching된 페이지를 얻음으로써, 빠른 웹 access.

  *  firewall 뒤의 사용자에게 특정 웹 접근을 가능하게 control

  * web content 의 filter 나 transform

 

 

Apache의 mod_proxy는 Forward Proxy와 Reverse Proxy를 지원하는데, Reverse Proxy는 caching을 통한 웹성능 향상외에  웹으로부터 방화벽뒤에있는 서버로의 controlled access를 가능하게 하기 위해 대부분 사용된다.

 

 - Forward Proxy : 서비스 서버의 앞에 서서 요청을 얻어옴. 방화벽을 뚫기위해 많이 설정함.

 - Reverse Proxy : 역시 서비스 서버의 앞에 서나 대행을 위해 사용됨.

 

 

Proxing with Apache

 

Standard Apache module인 mod_proxy는 HTTP/1.0 과 HTTP/1.1 두 protocol version을 지원하는데, HTTP/1.1이 rich new cache control mechanisims을 가진다는 점에서 큰 차이가 있다.

 

 

The Apache Proxy Modules

 

Apache modular arcitecture를 유지하기 위해서는, mod_proxy는 modular 자체이고, 전형적인 proxy server는 가능한 여러 모듈을 필요로 할 것이다. 이장에서는 proxing과 관련한 이런 모듈에 대한 설명을 주로 할 것이고,  caching 관련해서는 다루지 않는다.

 

mod_proxy: The core module deals with proxy infrastructure and configuration and managing a proxy request.
mod_proxy_http: This handles fetching documents with HTTP and HTTPS.
mod_proxy_ftp: This handles fetching documents with FTP.
mod_proxy_connect: This handles the CONNECT method for secure (SSL) tunneling.
mod_cache, mod_disk_cache, mod_mem_cache: These deal with managing a document cache. To enable caching requires mod_cache and one or both of disk_cache and mem_cache.
mod_proxy_html: This rewrites HTML links into a proxy's address space.
mod_headers: This modifies HTTP request and response headers.
mod_deflate: Negotiates compression with clients and backends.
 

 

Building Apache for Proxing ( Apache 2.0 기준)

 

mod_proxy_html을 제외하고, 위 모든 모듈이 core Apache distribution에 들어가있으므로, 쉽게 사용가능하다. (mod_proxy_html 설치는 위 사이트 참조하십시여 ㅡㅡ;)

 

Apache의 configure에서

$ ./configure --enable-so --enable-mods-shared="proxy \
proxy_http proxy_ftp proxy_connect headers"
$ make
# make install


간단히

./configure --enable-proxy --enable-proxy-http

 

기존 installation에 추가하기 위해서는 apxs를 써야한다.

# apxs -c -i [module-name].c
noting that mod_proxy itself is in two source files
(mod_proxy.c and proxy_util.c).


 

 

A Reverse Proxy Scenario

 

example.com이라는 회사가 internet을 통해 접근가능한 public IP address와 DNS entry를 가진 www.example.com이라는 website를 가지고 있다고 하자.

이 회사는 또한 방화벽 안에 private IP address와 등록되지 않은 DNS entry를 가진 여러 application server를 가지고 있다. 이런 해당 network안의 application server로internal1.example.com"과 "internal2.example.com" 이 있다고 하자. 이 서버들은 public DNS entry를 가지지 않으므로, 회사외부로 부터 internal1.example.com으로 접근이 안되고 "no such host" 에러가 날 것이다.

 

그런데, 이 application server로 web access를 해야된다고 결론이 난 것이다.  당연히 internet을 통해 직접적으로 노출하지는 말아야되고 해당 웹서버로 통합되긴 해야하므로,  내부적으로 http://www.example.com/app1/any-path-herehttp://internal1.example.com/any-path-here로 매핑하고 http;//www.example.com/app2/other-path-here를 http://internal2.example.com/other-path-here로 매핑하는 것이다.

 

Configuring the Proxy

 

이 모듈을 사용하기 위해서 우선 httpd.conf에 이것들을 loading 하라고 위 사이트에는 적혀있으나, 실제로  mod_proxy는 아파치와 static으로 link되기 때문에 LoadModule을 하지 않아도 되므로 여기선 생략하겠다.


proxy를 구성하기 전에, 우선 아래 중요한 securiy warning을 확인하자.

"ProxyRequests On" 으로 setting하지 말아라.

ProxyRequests 를 On으로 setting하면, 당신의 서버가 Open Proxy로 변해버린다.

web을 open proxy로 scan해버리는 인간들이 있어서, 이 서버를 불법적인 곳에 access하기위해 route하려고 사용하거나  심하게는 이 proxy를 통해 email spam을 route할 수도 있다.  얼마안가서  정상적인 traffic은 막혀버리고  family filter 같은 것에 의해 block당해버린 서버들을 발견하게 될 것이다.

물론 적절한 security measure로 forward proxy를 사용할 수 있으나, 여기선 다루지 않겠다.

 

reverse proxy를 설치하는 기본적인 configuration directive는 ProxyPass 이다.

해당 application server의 proxy rules를 set up하기 위해 아래와 같이 사용하면 된다.

 

ProxyPass /app1/ http://internal1.example.com/
ProxyPass /app2/ http://internal2.example.com/


그리고 apache를 재시작하면  http://www.example.com/app1/some-path-mapshttp://internal1.example.com/some-path 로 매핑되게 된다.

댓글목록

등록된 댓글이 없습니다.