cli(client) <-> myser(forwarding server) <-> rem(remote server)


일단 한쪽 방향으로 갈 때 데이터는 당연히 그대로 가는데

그대로 가면 문제일 것 같음


HTTP 리퀘스트 헤드 보면 Host부분이 있는데

클라이언트가 포워딩 서버에게 보낼 때는

당연히 호스트란에 포워딩 서버의 IP 주소와 포트가 적히는 게 맞지만(웹브라우저가 해주는 부분)

이걸 그대로 원격 서버에게 보내는 패킷에 포함시키면 안될 것 같네


실제 패킷이 향하는 호스트와 패킷의 내용에 적힌 호스트가 불일치하니

각 원격서버(웹사이트)들이 처리하는 방식에 따라 에러로 처리할 것 같음



일단 중간에 바꿔치기를 시도해보려 함


아래는 오고간 데이터 프린트 뽑은 것

구글에게 간 패킷은 포트 80으로 향했건만

그들이 나에게 보내는 패킷에는 로케이션의 포트가 50000으로 되어있음

내가 보낸 패킷의 호스트 내용을 기준으로 처리했나 봄

그래서 50000번 포트에는 문서 없다고 ㅈㄹ






######## cli to myser ########
GET / HTTP/1.1
Accept: text/html, application/xhtml+xml, image/jxr, */*
Accept-Language: ko,ja;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393
Accept-Encoding: gzip, deflate
Host: 192.168.0.2:50000
Connection: Keep-Alive


######## myser to rem ########
GET / HTTP/1.1
Accept: text/html, application/xhtml+xml, image/jxr, */*
Accept-Language: ko,ja;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393
Accept-Encoding: gzip, deflate
Host: 192.168.0.2:50000
Connection: Keep-Alive


######## rem to myser ########
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com:50000/
Content-Type: text/html; charset=UTF-8
Date: Mon, 26 Sep 2016 09:59:00 GMT
Expires: Wed, 26 Oct 2016 09:59:00 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 225
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com:50000/">here</A>.
</BODY></HTML>


######## myser to cli ########
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com:50000/
Content-Type: text/html; charset=UTF-8
Date: Mon, 26 Sep 2016 09:59:00 GMT
Expires: Wed, 26 Oct 2016 09:59:00 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 225
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com:50000/">here</A>.
</BODY></HTML>