I’ve been interested in learning Node.js and for a few times I’ve studied it but never finished a project or at least didn’t had the time!
A few days ago, after doing some research about the “NoBackend” concept, I got inspired and installed “Deployd” in my server and test it with very good results: very fast development, focus on the client-side, etc.
I’m interested in using this technology in my next project, so I did some research about how to put a Node.js app alongside with my other apps hosted in my Apache Server. I found a nice solution based on reverse-proxy withing Apache 2 - there’s other ways, but for small traffic sites this should be ok.
- Enable the Apache proxy modules. I’m using Ubuntu 12.04 LTS, so I edit /etc/apache2/httpd.conf and add the following:
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
1.1) I’ve assumed you’ve got the 2 modules installed and enabled:
ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled
- Now, edit your vhost and add the new directives:
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org ServerName yourdomain.com ServerAlias www.yourdomain.com ProxyRequests off ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ </VirtualHost>
- Restart apache2
service apache2 restart