Apache & NowJS/Node.js on same IP / different ports

118 views
Skip to first unread message

Craig Aschbrenner

unread,
May 17, 2011, 4:44:06 PM5/17/11
to no...@googlegroups.com
I'm new to NowJS / node.js and attempting to learn through the provided examples, etc.  Hopefully my question(s) won't be too stupid as I'm not quite sure yet where NowJS stops and node.js begins.

My end goal is to create chat functionality for the Drupal CMS.  I'm very familiar with Drupal but very new to NowJS / Node.js.  I plan on having Drupal render the client side html / javascript chat page, similar to the helloworld.html example provided with NowJS.  Since Drupal runs on the LAMP stack I'm looking at the various setup options for Drupal + NowJS.  After scouring and googling it looks like these are the possibilities...

1) Node server listening on port 80 and using node-http-proxy to send Drupal requests to apache on another port.

I was looking at this example but I'm lost as to what the apacheUrls should be to send Drupal requests through to apache.

2) Apache listening to port 80; Node listening on another port.  

In this case I'm not sure how the Drupal rendered chat page would connect to the node server on the same IP but with a different port.

3) Apache and Node on two different IPs.

Similar to #2 I'm not sure how to connect the Drupal rendered chat page to the node server.


Craig Aschbrenner

unread,
May 18, 2011, 12:04:54 AM5/18/11
to no...@googlegroups.com
I was successfully able to get option #1 working by modifying the example I had linked to.  I changed return url.match(req.url); to return url.test(req.url);.  I also set my apacheURLs variable to: 

var apacheURLs = [
  /.*\.html/,
  /.*\.js/,
  /.*\.css/,
  /.*\.png/,
  /.*\.ico/,
  /^\/$/
];

I believe I'm approaching this backwards however.  Most of my requests will be to the Drupal CMS.  Would it be easier to replace the apacheURLs with some sort of nodeURLs type variable?  And then check the req.url against the nodeURL variable to -not- proxy those URLs?

Craig Aschbrenner

unread,
May 18, 2011, 10:04:48 AM5/18/11
to no...@googlegroups.com
After struggling to get the helloworld example to work with option #1 above (node-http-proxy), I decided to give option #2 (apache on port 80, node on port 8080) a try.  Most of my traffic is for the drupal CMS and I'm only using node server to utilize nowjs.  Thanks to Eric's response on another issue of mine I simply referenced the now.js file as http://myserver:8080/nowjs/now.js.  I successfully have the helloworld example running as a drupal module.
Reply all
Reply to author
Forward
0 new messages