title: Proxy request to new port with http-proxy
body: <p>I use this code I want to create proxy that all the application calls to port 3000 will be routed "under the hood" to port 3002</p>
  
  <pre><code>var http = require('http'),
      httpProxy = require('http-proxy');
  
   var proxy = httpProxy.createProxyServer();
  
     http.createServer(function (req, res) {
      proxy.web(req, res, {
        target: 'http://localhost:3002'
      });
  }).listen(3000);
  
  // Create target server
  http.createServer(function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
    res.end();
  }).listen(3002);
  </code></pre>
  
  <p>Now when I run the application with original port(3000) I see in the browser </p>
  
  <p>request successfully proxied to 3002 </p>
  
  <ul>
  <li><p>When I change the port (in the browser ) to <strong>3002</strong> I still get the
  <strong>same</strong> message,why ? is it OK?</p></li>
  <li><p>What should I put in <strong>production</strong> inside the <strong>second</strong> create
  server ? I mean instead of the</p>
  
  <pre><code>res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
  res.end();
  </code></pre></li>
  <li><p>Does the <code>res.end()</code> should also be there ?</p></li>
  </ul>
  
  <p>I use the code from
  <a href="https://github.com/nodejitsu/node-http-proxy">https://github.com/nodejitsu/node-http-proxy</a></p>