{"id":988,"date":"2013-11-06T11:11:31","date_gmt":"2013-11-06T09:11:31","guid":{"rendered":"https:\/\/www.unicoda.com\/?p=988"},"modified":"2013-11-01T18:46:35","modified_gmt":"2013-11-01T16:46:35","slug":"12-lines-proxy-with-node-js-and-request","status":"publish","type":"post","link":"https:\/\/www.unicoda.com\/?p=988","title":{"rendered":"12 lines proxy with Node.js and Request"},"content":{"rendered":"<p>Easy and simple http proxy using Node.js and request.<\/p>\n<pre>var request = require('request')\r\n  , http = require('http')\r\n  , port = 8888\r\n  , host = 'localhost'\r\n  , proxy = http.createServer(function (req, res) {\r\n    var x = request(req.url)\r\n    req.pipe(x)\r\n    x.pipe(res)\r\n  })\r\nproxy.listen(port, host, function () {\r\n  console.log('Proxy running on port ' + port);\r\n})<\/pre>\n<p>Code available on Github: <a href=\"https:\/\/github.com\/vvision\/node-simple-proxy\">node-simple-proxy<\/a>.<\/p>\n<p>It would be great to support https. And of course, you can do it without request.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Easy and simple http proxy using Node.js and request. var request = require(&lsquo;request&rsquo;) , http = require(&lsquo;http&rsquo;) , port = 8888 , host = &lsquo;localhost&rsquo; , proxy = http.createServer(function (req, res) { var x = request(req.url) req.pipe(x) x.pipe(res) }) proxy.listen(port, host, function () { console.log(&lsquo;Proxy running on port &lsquo; + port); }) Code available on &hellip; <a href=\"https:\/\/www.unicoda.com\/?p=988\" class=\"more-link\">Continuer la lecture<span class=\"screen-reader-text\"> de &laquo;&nbsp;12 lines proxy with Node.js and Request&nbsp;&raquo;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[144,80],"class_list":["post-988","post","type-post","status-publish","format-standard","hentry","category-code","tag-node-js","tag-proxy"],"_links":{"self":[{"href":"https:\/\/www.unicoda.com\/index.php?rest_route=\/wp\/v2\/posts\/988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.unicoda.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.unicoda.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.unicoda.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.unicoda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=988"}],"version-history":[{"count":3,"href":"https:\/\/www.unicoda.com\/index.php?rest_route=\/wp\/v2\/posts\/988\/revisions"}],"predecessor-version":[{"id":1366,"href":"https:\/\/www.unicoda.com\/index.php?rest_route=\/wp\/v2\/posts\/988\/revisions\/1366"}],"wp:attachment":[{"href":"https:\/\/www.unicoda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unicoda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unicoda.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}