I’ve been pretty excited to pick up
nodejs for awhile now and I sat down today to get the ball rolling. I’ve installed node before and ran the basic ‘hello world’ example at work so I wanted to get right into it. Since I was anxious to at least get something out there on hour zero so I jumped straight into Heroku and created an app. While the process worked great and I got something up I was so excited about
node that I committed to picking it up and putting own server.
And that’s the first blocker. Sure - I want to put it on own server… but I run a lot of other things on my boxes. One of those things is a preexisting LAMP stack that hosts some tools that it would be tough to replace or go without. So that’s when my googling started.
I knew going into this that I was going to need to either need a second IP address or use a proxy. I opted for the path of least resistence and most practical: Proxy.
Not surprisingly there are a lot of brain dumps out there on this very subject, but I found them fairly tough to follow. Everyone has a stackoverflow question or forum post on how to tackle this problem and even a few “is this even ok?” questions.
Here’s what I discovered as my own solution:
This one is pretty straight forward.
Follow these steps and you’ll be set. https://gist.github.com/isaacs/579814#file-node-and-npm-in-30-seconds-sh
My only one add here is that I actually needed to add the local bin folder
~/local/bin to my
~/.bash_profile on MacOSX. I did not have this problem when installing on my Ubuntu box though.
I knew I was about to start redirecting from
localhost, so I wanted to ensure that my Ubuntu server knew that my
domain.com was the same as
127.0.0.1 to prevent any type of 503’s. Along this line I also went ahead and opened the 5000 port on my network. You can choose any port of your own, anything in that range should work.
And now for the important stuff… the proxy.
This will install the Apache2
Then, I needed to edit my default conf:
Then restart apache:
sudo service apache2 restart
Next I went ahead and created two files: web.js and package.json
After this we can then run
npm install from our node app directory, then:
sudo node web.js
Point our browsers to myawesomedomain.com/node and… success. :)