Blog / Node Foreeever
Once you start poking around with Node.js, you want to run it all the time like an Apache site. Sitting at localhost:3000 feels so artificial. But the journey to a seamless Node site on Mac OS is as arduous as the quest to return the One Ring.
Spoiler: you’re Boromir.
Step one was getting the Node site running on port 80 without bothering Apache. Turns out this is impossible, at least if you want to keep the threading benefits that Node provides. I’m on a dev machine, so I don’t care. After trying five different incantations I found one that seems to work. I added this to the bottom of my virtual host definition for the Node site:
ProxyRequests off <Proxy *> Order deny,allow Allow from all </Proxy> <Location /> ProxyPass http://localhost:3000/ ProxyPassReverse http://localhost:3000/ </Location>
Easy. I think. There’s a possibility this messes up POST commands. Haven’t got there yet with my app. With the Node app running I get great performance through Apache.
So screw it, I thought, I’ll start the Node server manually and let it run all day…
… and eat my battery like a juicy apple. After 30 minutes of sitting idle my laptop started to get warm. Oh, so Node (or nodemon?) isn’t quite the low resource supercar I was led to believe. Guess I’ll go back to running Node manually.