title: Python - How to create a tunnel of proxies
body: <p>I asked this question: <a href="https://stackoverflow.com/questions/46021477/wrap-packets-in-connect-requests-until-reach-the-last-proxy/46023292#46023292">Wrap packets in connect requests until reach the last proxy</a></p>
  
  <p>And I learnt that to create a chains of proxies I have to:</p>
  
  <ul>
  <li>create a socket</li>
  <li>connect the socket to proxy A</li>
  <li>create a tunnel via A    to proxy B - either with HTTP or SOCKS
  protocol similar </li>
  <li>create a    tunnel via [A,B] to proxy C similar</li>
  <li>create a tunnel via [A,B,C] to D</li>
  <li>... until your last proxy is instructed to built the tunnel to the<br>
  final target T</li>
  </ul>
  
  <p>I got what I have to do until the second point, cause I think I just have to add the "CONNECT" header to the http request to the proxy A. But my question is,
  in this example http request:</p>
  
  <pre><code>CONNECT ipproxy:80 HTTP/1.1
  Host: ?:80
  </code></pre>
  
  <p>In the host header I should put again the proxy ip or something else? Like the proxy B ip or the final site domain?</p>
  
  <p>Also, I didn't understand how to go on from the third point to the next... because I don't know how to tell the proxy A to create a tunnel to proxyB and then proxy B to create a tunnel to proxy C that goes to the final site..</p>
  
  <p>Examples of how can I do it with python? Or some doc?</p>