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 <[email protected]> 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 <[email protected]> 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 [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to