BTW: httpProxy.createServer(...) can proxy websocket-requests. And it supports ssl connections.
On Tue, May 29, 2012 at 11:24 AM, Axel Kittenberger <axk...@gmail.com> wrote: > Awesome, thanks! > > On Tue, May 29, 2012 at 11:03 AM, Oliver Leics <oliver.le...@gmail.com> wrote: >> var http = require('http') >> , httpProxy = require('http-proxy') >> , proxy = new httpProxy.RoutingProxy() >> ; >> >> http.createServer(function(req, res) { >> if(req.headers.host === 'whatever.example.com') { >> proxy.proxyRequest(req, res, >> { host: 'localhost' >> , port: '8080' >> } >> ) >> return >> } >> >> res.writeHead(400) >> res.end('Bad Request: Unknown "Host"') >> }).listen(80) >> >> - o >> >> On Tue, May 29, 2012 at 10:16 AM, Axel Kittenberger <axk...@gmail.com> wrote: >>> No. All of the examples proxy through httpProxy.createServer >>> >>> On Tue, May 29, 2012 at 9:48 AM, Marak Squires <marak.squi...@gmail.com> >>> wrote: >>>> Yes. https://github.com/nodejitsu/node-http-proxy/tree/master/examples >>>> >>>> >>>> On Tue, May 29, 2012 at 12:25 AM, Axel Kittenberger <axk...@gmail.com> >>>> wrote: >>>>> >>>>> Thank you. >>>>> >>>>> The thing that confuses me is, why httpProxy.createServer(...); >>>>> >>>>> Cant I just create http.createServer() handle requests normally for >>>>> the main node site, and in my request handler create a proxyRequst >>>>> only when it relates the VHOST? >>>>> >>>>> On Tue, May 29, 2012 at 9:14 AM, Oliver Leics <oliver.le...@gmail.com> >>>>> wrote: >>>>> > var httpProxy = require('http-proxy') >>>>> > ; >>>>> > >>>>> > httpProxy.createServer(options, function(req, res, proxy) { >>>>> > if(req.headers.host === 'whatever.example.com') { >>>>> > proxy.proxyRequest(req, res, >>>>> > { host: 'localhost' >>>>> > , port: '8080' >>>>> > } >>>>> > ) >>>>> > return >>>>> > } >>>>> > res.writeHead(400, {}) >>>>> > res.write('Bad Request: Missing "Host"') >>>>> > res.end() >>>>> > }) >>>>> > >>>>> > - o >>>>> > >>>>> > On Tue, May 29, 2012 at 9:06 AM, Axel Kittenberger <axk...@gmail.com> >>>>> > wrote: >>>>> >> Hi list, yet another question (I know its getting much in the last days >>>>> >> :-). >>>>> >> >>>>> >> Suppose I want to host a second legacy website with Apache-PhP on my >>>>> >> VPS otherwise running awesome node.js (not my blog, its yet something >>>>> >> else). So I check request.headers.host and if its the VHOST for the >>>>> >> legacy website, I want to proxy that request to say localhost port >>>>> >> 8080 running the Apache. >>>>> >> >>>>> >> Any code snippets to properly and compactly proxy GET as well POST >>>>> >> requests? >>>>> >> >>>>> >> I've seen node-http-proxy, but its Documentation only explains howto >>>>> >> set up a standalone (reverse)proxy rather than integrate it to an >>>>> >> existing node.js server occupying the port 80. >>>>> >> >>>>> >> -- >>>>> >> Job Board: http://jobs.nodejs.org/ >>>>> >> Posting guidelines: >>>>> >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >>>>> >> You received this message because you are subscribed to the Google >>>>> >> Groups "nodejs" group. >>>>> >> To post to this group, send email to nodejs@googlegroups.com >>>>> >> To unsubscribe from this group, send email to >>>>> >> nodejs+unsubscr...@googlegroups.com >>>>> >> For more options, visit this group at >>>>> >> http://groups.google.com/group/nodejs?hl=en?hl=en >>>>> > >>>>> > >>>>> > >>>>> > -- >>>>> > Oliver Leics @ G+ >>>>> > https://plus.google.com/112912441146721682527 >>>>> > >>>>> > -- >>>>> > Job Board: http://jobs.nodejs.org/ >>>>> > Posting guidelines: >>>>> > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >>>>> > You received this message because you are subscribed to the Google >>>>> > Groups "nodejs" group. >>>>> > To post to this group, send email to nodejs@googlegroups.com >>>>> > To unsubscribe from this group, send email to >>>>> > nodejs+unsubscr...@googlegroups.com >>>>> > For more options, visit this group at >>>>> > http://groups.google.com/group/nodejs?hl=en?hl=en >>>>> >>>>> -- >>>>> Job Board: http://jobs.nodejs.org/ >>>>> Posting guidelines: >>>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >>>>> You received this message because you are subscribed to the Google >>>>> Groups "nodejs" group. >>>>> To post to this group, send email to nodejs@googlegroups.com >>>>> To unsubscribe from this group, send email to >>>>> nodejs+unsubscr...@googlegroups.com >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/nodejs?hl=en?hl=en >>>> >>>> >>>> >>>> >>>> -- >>>> -- >>>> Marak Squires >>>> Co-founder and Chief Evangelist >>>> Nodejitsu, Inc. >>>> marak.squi...@gmail.com >>>> >>>> -- >>>> Job Board: http://jobs.nodejs.org/ >>>> Posting guidelines: >>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >>>> You received this message because you are subscribed to the Google >>>> Groups "nodejs" group. >>>> To post to this group, send email to nodejs@googlegroups.com >>>> To unsubscribe from this group, send email to >>>> nodejs+unsubscr...@googlegroups.com >>>> For more options, visit this group at >>>> http://groups.google.com/group/nodejs?hl=en?hl=en >>> >>> -- >>> Job Board: http://jobs.nodejs.org/ >>> Posting guidelines: >>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >>> You received this message because you are subscribed to the Google >>> Groups "nodejs" group. >>> To post to this group, send email to nodejs@googlegroups.com >>> To unsubscribe from this group, send email to >>> nodejs+unsubscr...@googlegroups.com >>> For more options, visit this group at >>> http://groups.google.com/group/nodejs?hl=en?hl=en >> >> >> >> -- >> Oliver Leics @ G+ >> https://plus.google.com/112912441146721682527 >> >> -- >> Job Board: http://jobs.nodejs.org/ >> Posting guidelines: >> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines >> You received this message because you are subscribed to the Google >> Groups "nodejs" group. >> To post to this group, send email to nodejs@googlegroups.com >> To unsubscribe from this group, send email to >> nodejs+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/nodejs?hl=en?hl=en > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to nodejs@googlegroups.com > To unsubscribe from this group, send email to > nodejs+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en -- Oliver Leics @ G+ https://plus.google.com/112912441146721682527 -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en