title: What can go wrong with ssh port-forwarding HTTP/HTTPS sites?
body: <p>I am trying to figure out how <code>ssh</code> port forwarding works. I'm very puzzled as to the different problems I am seeing.</p>
  
  <p>First, a basic example: <code>ssh -L 8080:www.ubuntuforums.org:80 localhost</code>. After logging into my local machine, navigating to <code>localhost:8080</code> in Chrome gets me to <code>http://www.canonical.com/</code>. If I navigate directly to <code>http://www.ubuntuforums.org/</code> in my Chrome, I instead end up at <code>http://ubuntuforums.org/</code>. What is going on here? Why do I not end up at <code>ubuntuforums.org</code> but instead <code>www.canonical.com</code>?</p>
  
  <p>Second, changing the website and port: <code>ssh -L 8888:learnlayout.com:80 localhost</code>. Navigating to <code>http://localhost:8888</code> in Chrome I just hang forever. <code>wget http://localhost:8888</code> gives me the following <code>index.html</code>:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Transmission Forward&lt;/title&gt;
  &lt;script type="text/javascript"&gt;
  window.location = "http://24.218.24.189:8080/"
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p&gt;Stand By...&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Is <code>ssh</code> not handling redirects correctly or something when I point to it in my browser?</p>
  
  <p>Third, <code>ssh -L 8888:imgur.com:80 localhost</code>. In my browser I get the following error: <code>Fastly error: unknown domain: localhost. Please check that this domain has been added to a service.</code>. <code>wget localhost:8888</code> gives me:</p>
  
  <pre><code>--2016-05-07 16:36:47--  http://localhost:8887/
  Resolving localhost... ::1, 127.0.0.1
  Connecting to localhost|::1|:8888... connected.
  HTTP request sent, awaiting response... 500 Domain Not Found
  2016-05-07 16:36:47 ERROR 500: Domain Not Found.
  </code></pre>
  
  <p>This diversity of errors is really befuddling me. Is there anything obvious about <code>ssh</code> tunneling I am missing? Should these be working and maybe my network or router is up to something?</p>