Nginx 전송 에이전트 설정

3217 단어 nginx
    :zhanhailiang   :2013-01-29

필요:
        ,   www.hwtrip.com   itravel.smartcom.cc 。

생각:
     itravel.smartcom.cc/trip/****,  Nginx      www.hwtrip.com/$1?$query_string&from=itravel。

방법:
  Nginx  :  location /trip/   ,       www.hwtrip.com/$1?from=itravel
#          URI         /trip/,      ~,    ~,              trip  ,  【location】【간단 한 PHP 사이트 설정】【location
location ~ /trip/ {
    proxy_pass                             http://www.hwtrip.com:80;
    proxy_redirect                         default;
    proxy_set_header    Host               www.hwtrip.com;
    proxy_set_header    X-Real-IP          $remote_addr;
    proxy_set_header    X-Forwarded-For    $proxy_add_x_forwarded_for;
    #                     ,  【rewrite
    rewrite             ^/trip/(.*)$       /$1?from=itravel break; 
    break;
}

마지막 테스트 용례 는 다음 과 같다.
==>     <==
GET /trip/t.html HTTP/1.1
Host: itravel.smartcom.cc
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: ******

==>     <==
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 29 Jan 2013 07:38:11 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: close
Content-Encoding: gzip

좋은 웹페이지 즐겨찾기